fix(modal, popover): warn if trigger element was not found (#26650)

This commit is contained in:
Liam DeBeasi
2023-01-20 15:04:16 -05:00
committed by GitHub
parent 6b16a0c020
commit 1115203120
2 changed files with 17 additions and 0 deletions

View File

@ -402,8 +402,16 @@ export class Modal implements ComponentInterface, OverlayInterface {
destroyTriggerInteraction();
}
if (trigger === undefined) {
return;
}
const triggerEl = trigger !== undefined ? document.getElementById(trigger) : null;
if (!triggerEl) {
printIonWarning(
`A trigger element with the ID "${trigger}" was not found in the DOM. The trigger element must be in the DOM when the "trigger" property is set on ion-modal.`,
this.el
);
return;
}