Skip to content

Commit c524693

Browse files
authored
[Overlay2]: Remove defaultProps from component (#7517)
1 parent 205681a commit c524693

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

packages/core/src/components/dialog/dialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Button } from "../button/buttons";
3333
import { H6 } from "../html/html";
3434
import { Icon } from "../icon/icon";
3535
import type { BackdropProps, OverlayableProps } from "../overlay/overlayProps";
36-
import { Overlay2, OVERLAY2_DEFAULT_PROPS } from "../overlay2/overlay2";
36+
import { Overlay2 } from "../overlay2/overlay2";
3737

3838
export interface DialogProps extends OverlayableProps, BackdropProps, Props {
3939
/** Dialog contents. */
@@ -146,7 +146,7 @@ export class Dialog extends AbstractPureComponent<DialogProps> {
146146
<div
147147
className={classNames(Classes.DIALOG, className)}
148148
role={role}
149-
aria-modal={overlayProps.enforceFocus ?? OVERLAY2_DEFAULT_PROPS.enforceFocus}
149+
aria-modal={overlayProps.enforceFocus ?? true}
150150
aria-labelledby={this.props["aria-labelledby"] || (title ? this.titleId : undefined)}
151151
aria-describedby={this.props["aria-describedby"]}
152152
style={style}

packages/core/src/components/overlay2/overlay2.tsx

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,52 +73,37 @@ export interface Overlay2Props extends OverlayProps, React.RefAttributes<Overlay
7373
childRefs?: Record<string, React.RefObject<HTMLElement>>;
7474
}
7575

76-
export const OVERLAY2_DEFAULT_PROPS = {
77-
autoFocus: true,
78-
backdropProps: {},
79-
canEscapeKeyClose: true,
80-
canOutsideClickClose: true,
81-
enforceFocus: true,
82-
hasBackdrop: true,
83-
isOpen: false,
84-
lazy: hasDOMEnvironment(),
85-
shouldReturnFocusOnClose: true,
86-
transitionDuration: 300,
87-
transitionName: Classes.OVERLAY,
88-
usePortal: true,
89-
};
90-
9176
/**
9277
* Overlay2 component.
9378
*
9479
* @see https://blueprintjs.com/docs/#core/components/overlay2
9580
*/
9681
export const Overlay2 = forwardRef<OverlayInstance, Overlay2Props>((props, forwardedRef) => {
9782
const {
98-
autoFocus,
83+
autoFocus = true,
9984
backdropClassName,
100-
backdropProps,
101-
canEscapeKeyClose,
102-
canOutsideClickClose,
85+
backdropProps = {},
86+
canEscapeKeyClose = true,
87+
canOutsideClickClose = true,
10388
childRef,
10489
childRefs,
10590
children,
10691
className,
107-
enforceFocus,
108-
hasBackdrop,
109-
isOpen,
110-
lazy,
92+
enforceFocus = true,
93+
hasBackdrop = true,
94+
isOpen = false,
95+
lazy = hasDOMEnvironment(),
11196
onClose,
11297
onClosed,
11398
onClosing,
11499
onOpened,
115100
onOpening,
116101
portalClassName,
117102
portalContainer,
118-
shouldReturnFocusOnClose,
119-
transitionDuration,
120-
transitionName,
121-
usePortal,
103+
shouldReturnFocusOnClose = true,
104+
transitionDuration = 300,
105+
transitionName = Classes.OVERLAY,
106+
usePortal = true,
122107
} = props;
123108

124109
useOverlay2Validation(props);
@@ -672,8 +657,7 @@ export const Overlay2 = forwardRef<OverlayInstance, Overlay2Props>((props, forwa
672657
return transitionGroup;
673658
}
674659
});
675-
// eslint-disable-next-line @typescript-eslint/no-deprecated
676-
Overlay2.defaultProps = OVERLAY2_DEFAULT_PROPS;
660+
677661
Overlay2.displayName = `${DISPLAYNAME_PREFIX}.Overlay2`;
678662

679663
function useOverlay2Validation({ childRef, childRefs, children }: Overlay2Props) {

0 commit comments

Comments
 (0)