-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(menu): emit ionMenuChange when re-mounted #28049
Conversation
Run & review this pull request in StackBlitz Codeflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most minor nit, implementation looks good.
Co-authored-by: Sean Perkins <[email protected]>
</ion-header> | ||
<ion-content class="ion-padding"> | ||
Main Content | ||
<button onclick="trigger()" id="trigger">Add Menu To DOM</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I click the button multiple times, the menu is still present in the DOM but the menu button disappears; is that what's supposed to happen? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like connectedCallback fires then disconnectedCallback, so it could be a Stencil bug. I was able to reproduce this behavior even after I removed the fix.
Issue number: resolves #28030
What is the current behavior?
ion-menu
registers itself with the menu controller whenconnectedCallback
fires and then unregisters itself whendisconnectedCallback
fires. When the menu was removed from the DOM,disconnectedCallback
was not always being fired due to ionic-team/stencil#4070.ion-menu-button
checks to see if it should be visible by grabbing the current menu inionic-framework/core/src/components/menu-button/menu-button.tsx
Line 74 in 314055c
Since
disconnectedCallback
was not being fired,ion-menu-button
would still find the menu even when it was no longer in the DOM. In this case, the menu was not being unregistered due todisconnectedCallback
not firing.When the linked Stencil bug was resolved in Stencil 4.0.3, the menu button started to disappear. This is happening because
disconnectedCallback
is now correctly called when the menu is removed from the DOM. SincedisconnectedCallback
is called, the menu is un-registered from the menu controller, and the menu button can no longer find it.However, this revealed a long-standing bug where re-adding the menu would not fire
ionMenuChange
again. As a result, the menu button remained hidden.What is the new behavior?
ionMenuChange
onconnectedCallback
as long ascomponentDidLoad
has already been run.Does this introduce a breaking change?
Other information
Dev build:
7.3.2-dev.11692803611.15c1bc87