IONIC 4 closing menu problems

In 2018 there was this post with solutions https://github.com/ionic-team/ionic/issues/3476
But I’m trying it right now and neither menuClose nor menu-close actually work, has this been updated?

Is this for a button within the ion-menu?

Welp in my side menu I have an ion-menu, then an ion-list and one of the ion-item is a LogOut button, as an ion-item button, I wanted it to close the menu while also firing a method to log out the user, but the tags weren’t closing the menu, I’ve done it using MenuController now, but I was just wondering how come none of the tags that worked a year ago work now, or if mby I was just doing wrong.

Ion-menu-toggle

Wrap your logout button in this tag, and any menu button you want to close the menu

3 Likes

Yeeep it works now, thanks!

I know this is sort of another topic but do you have any idea why is it that I’m subscribing to the ionDidClose event but it is not firing when I’m closing the menu using the toggle wrapper? https://ionicframework.com/docs/api/menu#events
image

I tried subscribing on the item to the event by doing (ionDidClose)=“someMethod()” but it isn’t firing

1 Like

I think you’ll want that (ionDidClose) in the ion-menu tag, not the ion-item. But that will fire logout() every time your menu closes

2 Likes

Now that I think of it, yeah that’s really a problem, I need it to only execute logout() when he specifically closes the menu by using the log out button

Shouldnt it be executing on (click) on the item/button?

Yeah I was trying to avoid it for a very peculiar graphical reason, reason why I wanted the event after closing, first do the menu closing animation, THEN execute code, in click it executes code right away.
What I ended up doing was in the method I set a delay in the code while the animation is executing and once the animation is over, so is the delay, and the code finally executes.
Thanks for your help again buddy

edit: ended up using 300 ms as a delay, its perfect

Ah nice workaround. Good luck