fix(react): checking isOpen again after async call before opening overlay, fixes #19755

This commit is contained in:
Ely Lucas
2019-10-28 10:20:45 -06:00
parent 29f8178794
commit 67737bbb54

View File

@ -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 {