mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
fix(modal, popover): warn if trigger element was not found (#26650)
This commit is contained in:
@ -402,8 +402,16 @@ export class Modal implements ComponentInterface, OverlayInterface {
|
|||||||
destroyTriggerInteraction();
|
destroyTriggerInteraction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trigger === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const triggerEl = trigger !== undefined ? document.getElementById(trigger) : null;
|
const triggerEl = trigger !== undefined ? document.getElementById(trigger) : null;
|
||||||
if (!triggerEl) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import type { ComponentInterface, EventEmitter } from '@stencil/core';
|
import type { ComponentInterface, EventEmitter } from '@stencil/core';
|
||||||
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
|
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
|
||||||
|
import { printIonWarning } from '@utils/logging';
|
||||||
|
|
||||||
import { getIonMode } from '../../global/ionic-global';
|
import { getIonMode } from '../../global/ionic-global';
|
||||||
import type {
|
import type {
|
||||||
@ -620,8 +621,16 @@ export class Popover implements ComponentInterface, PopoverInterface {
|
|||||||
destroyTriggerInteraction();
|
destroyTriggerInteraction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trigger === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const triggerEl = (this.triggerEl = trigger !== undefined ? document.getElementById(trigger) : null);
|
const triggerEl = (this.triggerEl = trigger !== undefined ? document.getElementById(trigger) : null);
|
||||||
if (!triggerEl) {
|
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-popover.`,
|
||||||
|
this.el
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user