fix(modal/popover): lifecycle events

fixes #15806
This commit is contained in:
Manu Mtz.-Almeida
2018-10-08 14:28:15 -05:00
parent 11aa241dac
commit 19c449e815
3 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import { AnimationBuilder, BackButtonEvent, HTMLIonOverlayElement, IonicConfig,
let lastId = 0;
export function createOverlay<T extends HTMLIonOverlayElement>(element: T, opts: object | undefined): Promise<T> {
const doc = element.ownerDocument;
const doc = element.ownerDocument!;
connectListeners(doc);
// convert the passed in overlay options into props
@ -152,16 +152,17 @@ async function overlayAnimation(
}
if (overlay.keyboardClose) {
animation.beforeAddWrite(() => {
const activeElement = baseEl.ownerDocument.activeElement as HTMLElement;
const activeElement = baseEl.ownerDocument!.activeElement as HTMLElement;
if (activeElement && activeElement.matches('input, ion-input, ion-textarea')) {
activeElement.blur();
}
});
}
await animation.playAsync();
const hasCompleted = animation.hasCompleted;
animation.destroy();
overlay.animation = undefined;
return animation.hasCompleted;
return hasCompleted;
}
}