fix(menu-toggle): fix race condition by checking for menu-toggle visibility after a menu registers with the menu-controller

This commit is contained in:
Dan Bucholtz
2018-02-23 09:49:14 -06:00
parent 7377590d16
commit 7694576068
4 changed files with 12 additions and 4 deletions

View File

@ -30,8 +30,9 @@ export class MenuToggle {
@Listen('body:ionMenuDisable')
@Listen('body:ionSplitPaneVisible')
@Listen('body:ionMenuRegister')
updateVisibility() {
getMenuController().then(menuCtrl => {
return getMenuController().then(menuCtrl => {
if (menuCtrl) {
const menu = menuCtrl.get(this.menu);
if (menu && menu.isActive()) {

View File

@ -40,13 +40,14 @@
<ion-content padding>
<ion-list>
<ion-menu-toggle>
<!-- <ion-menu-toggle> -->
<ion-item>
<ion-label>
List Item
No Menu Toggle
</ion-label>
</ion-item>
</ion-menu-toggle>
<!-- </ion-menu-toggle> -->
<ion-menu-toggle>
<ion-item>

View File

@ -127,6 +127,8 @@ export class Menu {
@Event() protected ionMenuDisable: EventEmitter;
@Event() protected ionMenuRegister: EventEmitter;
componentWillLoad() {
return this.lazyMenuCtrl.componentOnReady().then(menu => {
this.menuCtrl = menu;
@ -163,6 +165,7 @@ export class Menu {
}
// register this menu with the app's menu controller
this.menuCtrl._register(this);
this.ionMenuRegister.emit();
// mask it as enabled / disabled
this.disabled = !isEnabled;

View File

@ -137,6 +137,9 @@ It reports the relative position.
#### ionMenuDisable
#### ionMenuRegister
#### ionOpen
Emitted when the menu is open.