fix(react): create a new overlay each time component is presented, fixes #19841, #19823 (#19842)

This commit is contained in:
Ely Lucas
2019-11-05 16:49:10 -07:00
committed by Ely Lucas
parent e5e9dd5dfe
commit 2f5d823748

View File

@ -54,18 +54,15 @@ export const createControllerComponent = <OptionsType extends object, OverlayTyp
async present(prevProps?: Props) { async present(prevProps?: Props) {
const { isOpen, onDidDismiss, ...cProps } = this.props; const { isOpen, onDidDismiss, ...cProps } = this.props;
let overlay = this.overlay; this.overlay = await controller.create({
if (!overlay) { ...cProps as any
overlay = this.overlay = await controller.create({ });
...cProps as any attachProps(this.overlay, {
});
}
attachProps(overlay, {
[dismissEventName]: onDidDismiss [dismissEventName]: onDidDismiss
}, prevProps); }, prevProps);
// Check isOpen again since the value could of changed during the async call to controller.create // Check isOpen again since the value could of changed during the async call to controller.create
if (this.props.isOpen === true) { if (this.props.isOpen === true) {
await overlay.present(); await this.overlay.present();
} }
} }