Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] feat(Dialog): add containerRef prop #5314

Merged
merged 9 commits into from
May 27, 2022
9 changes: 7 additions & 2 deletions packages/core/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import classNames from "classnames";
import * as React from "react";

import { AbstractPureComponent2, Classes } from "../../common";
import { AbstractPureComponent2, Classes, IRef } from "../../common";
import * as Errors from "../../common/errors";
import { DISPLAYNAME_PREFIX, MaybeElement, Props } from "../../common/props";
import { uniqueId } from "../../common/utils";
Expand Down Expand Up @@ -80,6 +80,11 @@ export interface IDialogProps extends OverlayableProps, IBackdropProps, Props {
*/
transitionName?: string;

/**
* Ref supplied to the `Classes.DIALOG_CONTAINER` element.
*/
dialogRef?: IRef<HTMLDivElement>;
dlichen marked this conversation as resolved.
Show resolved Hide resolved

/**
* ID of the element that contains title or label text for this dialog.
*
Expand Down Expand Up @@ -114,7 +119,7 @@ export class Dialog extends AbstractPureComponent2<DialogProps> {
public render() {
return (
<Overlay {...this.props} className={Classes.OVERLAY_SCROLL_CONTAINER} hasBackdrop={true}>
<div className={Classes.DIALOG_CONTAINER}>
<div className={Classes.DIALOG_CONTAINER} ref={this.props.dialogRef}>
<div
className={classNames(Classes.DIALOG, this.props.className)}
role="dialog"
Expand Down