From fe8d74d08cb919ed1c685262f0aed4a544c3a7e1 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 26 Feb 2020 15:54:50 -0500 Subject: [PATCH] fix(menu): allow ssr to work properly with hardware back button updates (#20629) --- core/src/utils/menu-controller/index.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/utils/menu-controller/index.ts b/core/src/utils/menu-controller/index.ts index 87a12298f81..25eb5e73701 100644 --- a/core/src/utils/menu-controller/index.ts +++ b/core/src/utils/menu-controller/index.ts @@ -207,15 +207,17 @@ 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(); - }); - } - }); + /* tslint:disable-next-line */ + if (typeof document !== 'undefined') { + document.addEventListener('ionBackButton', (ev: any) => { + const openMenu = _getOpenSync(); + if (openMenu) { + (ev as BackButtonEvent).detail.register(MENU_BACK_BUTTON_PRIORITY, () => { + return openMenu.close(); + }); + } + }); + } return { registerAnimation,