mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(overlay): register backbutton handler only when needed (#15615)
Fixes #15601. When listening to ionBackButton events, only registers the backbutton handler if there is actually an overlay. This will give a chance to handlers with lower priority to eventually run.
This commit is contained in:
@ -34,7 +34,11 @@ export function connectListeners(doc: Document) {
|
|||||||
if (lastId === 0) {
|
if (lastId === 0) {
|
||||||
lastId = 1;
|
lastId = 1;
|
||||||
doc.addEventListener('ionBackButton', ev => {
|
doc.addEventListener('ionBackButton', ev => {
|
||||||
(ev as BackButtonEvent).detail.register(100, () => closeTopOverlay(doc));
|
const lastOverlay = getOverlay(doc);
|
||||||
|
// We use the overlayIndex property to be sure this node is an overlay
|
||||||
|
if (lastOverlay && lastOverlay.overlayIndex) {
|
||||||
|
(ev as BackButtonEvent).detail.register(100, () => closeTopOverlay(doc));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addEventListener('keyup', ev => {
|
doc.addEventListener('keyup', ev => {
|
||||||
|
Reference in New Issue
Block a user