-
Notifications
You must be signed in to change notification settings - Fork 77
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(action-menu): fix toggle logic when action-menu
is reconnected
#11139
Conversation
@@ -319,6 +319,8 @@ export class ActionMenu extends LitElement implements LoadableComponent { | |||
"keydown", | |||
this.menuButtonKeyDown, | |||
) /* TODO: [MIGRATION] If possible, refactor to use on* JSX prop or this.listen()/this.listenOn() utils - they clean up event listeners automatically, thus prevent memory leaks */; | |||
|
|||
this.menuButtonEl = null; |
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.
Not clearing this reference would cause connectMenuButtonEl
to bail since the references would remain the same.
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.
👍
@@ -334,7 +336,10 @@ export class ActionMenu extends LitElement implements LoadableComponent { | |||
|
|||
private setDefaultMenuButtonEl(el: Action["el"]): void { | |||
this.defaultMenuButtonEl = el; | |||
this.connectMenuButtonEl(); | |||
|
|||
if (el) { |
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.
Seems like a lot of components might need this kind of if statement since this is similar to some other fixes 👍
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.
Agreed. I created #11093 to take a closer look, but it might be easier for the time being to return early when the reference element is null in all cases (preserves existing component logic based on Stencil lifecycle). WDYT?
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.
Yeah I think that might be the easiest and most consistent solution.
Related Issue: #10731
Summary
Fixes a regression caused by #10310 where the change to the internal popover to use
triggerDisabled
would no longer work when the component was reconnected.