Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/react/src/components/createOverlayComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ export const createOverlayComponent = <
forwardedRef?: React.ForwardedRef<OverlayType>;
};

let isDismissing = false;

class Overlay extends React.Component<Props> {
overlay?: OverlayType;
el!: HTMLDivElement;

isDismissing = false;
constructor(props: Props) {
super(props);
if (typeof document !== 'undefined') {
Expand Down Expand Up @@ -75,7 +73,7 @@ export const createOverlayComponent = <
shouldComponentUpdate(nextProps: Props) {
// Check if the overlay component is about to dismiss
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
isDismissing = true;
this.isDismissing = true;
}

return true;
Expand All @@ -91,7 +89,7 @@ export const createOverlayComponent = <
}
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
await this.overlay.dismiss();
isDismissing = false;
this.isDismissing = false;

/**
* Now that the overlay is dismissed
Expand Down Expand Up @@ -142,7 +140,7 @@ export const createOverlayComponent = <
* overlay is dismissing otherwise component
* will be hidden before animation is done.
*/
return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
return ReactDOM.createPortal(this.props.isOpen || this.isDismissing ? this.props.children : null, this.el);
}
}

Expand Down