mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
merge release-7.7.0
Release 7.7.0
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { doc } from '@utils/browser';
|
||||
import type { BackButtonEvent } from '@utils/hardware-back-button';
|
||||
import { shoudUseCloseWatcher } from '@utils/hardware-back-button';
|
||||
|
||||
import { config } from '../global/config';
|
||||
import { getIonMode } from '../global/ionic-global';
|
||||
@ -353,20 +354,39 @@ const connectListeners = (doc: Document) => {
|
||||
const lastOverlay = getPresentedOverlay(doc);
|
||||
if (lastOverlay?.backdropDismiss) {
|
||||
(ev as BackButtonEvent).detail.register(OVERLAY_BACK_BUTTON_PRIORITY, () => {
|
||||
return lastOverlay.dismiss(undefined, BACKDROP);
|
||||
/**
|
||||
* Do not return this promise otherwise
|
||||
* the hardware back button utility will
|
||||
* be blocked until the overlay dismisses.
|
||||
* This is important for a modal with canDismiss.
|
||||
* If the application presents a confirmation alert
|
||||
* in the "canDismiss" callback, then it will be impossible
|
||||
* to use the hardware back button to dismiss the alert
|
||||
* dialog because the hardware back button utility
|
||||
* is blocked on waiting for the modal to dismiss.
|
||||
*/
|
||||
lastOverlay.dismiss(undefined, BACKDROP);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// handle ESC to close overlay
|
||||
doc.addEventListener('keydown', (ev) => {
|
||||
if (ev.key === 'Escape') {
|
||||
const lastOverlay = getPresentedOverlay(doc);
|
||||
if (lastOverlay?.backdropDismiss) {
|
||||
lastOverlay.dismiss(undefined, BACKDROP);
|
||||
/**
|
||||
* Handle ESC to close overlay.
|
||||
* CloseWatcher also handles pressing the Esc
|
||||
* key, so if a browser supports CloseWatcher then
|
||||
* this behavior will be handled via the ionBackButton
|
||||
* event.
|
||||
*/
|
||||
if (!shoudUseCloseWatcher()) {
|
||||
doc.addEventListener('keydown', (ev) => {
|
||||
if (ev.key === 'Escape') {
|
||||
const lastOverlay = getPresentedOverlay(doc);
|
||||
if (lastOverlay?.backdropDismiss) {
|
||||
lastOverlay.dismiss(undefined, BACKDROP);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user