Skip to content

Commit

Permalink
fix(react): checking isOpen again after async call before opening ove…
Browse files Browse the repository at this point in the history
…rlay, fixes #19755
  • Loading branch information
elylucas committed Oct 28, 2019
1 parent 31c754d commit f70e71a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/react/src/components/createControllerComponent.tsx
Expand Up @@ -54,13 +54,19 @@ export const createControllerComponent = <OptionsType extends object, OverlayTyp

async present(prevProps?: Props) {
const { isOpen, onDidDismiss, ...cProps } = this.props;
const overlay = this.overlay = await controller.create({
...cProps as any
});
let overlay = this.overlay;
if (!overlay) {
overlay = this.overlay = await controller.create({
...cProps as any
});
}
attachProps(overlay, {
[dismissEventName]: onDidDismiss
}, prevProps);
await overlay.present();
// Check isOpen again since the value could of changed during the async call to controller.create
if (this.props.isOpen === true) {
await overlay.present();
}
}

render(): null {
Expand Down

0 comments on commit f70e71a

Please sign in to comment.