mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(menu): hardware back button now dismisses side menu if open (#20558)
fixes #20559
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { AnimationBuilder, MenuI } from '../../interface';
|
||||
import { AnimationBuilder, BackButtonEvent, MenuI } from '../../interface';
|
||||
import { MENU_BACK_BUTTON_PRIORITY } from '../hardware-back-button';
|
||||
|
||||
import { menuOverlayAnimation } from './animations/overlay';
|
||||
import { menuPushAnimation } from './animations/push';
|
||||
@ -206,6 +207,16 @@ const createMenuController = () => {
|
||||
registerAnimation('push', menuPushAnimation);
|
||||
registerAnimation('overlay', menuOverlayAnimation);
|
||||
|
||||
const doc: Document = document;
|
||||
doc.addEventListener('ionBackButton', (ev: any) => {
|
||||
const openMenu = _getOpenSync();
|
||||
if (openMenu) {
|
||||
(ev as BackButtonEvent).detail.register(MENU_BACK_BUTTON_PRIORITY, () => {
|
||||
return openMenu.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
registerAnimation,
|
||||
get,
|
||||
|
||||
Reference in New Issue
Block a user