Skip to content
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

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

jcfranco
Copy link
Member

@jcfranco jcfranco commented Dec 23, 2024

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.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Dec 23, 2024
@jcfranco jcfranco added the no changelog entry Use the commit override to avoid a changelog entry label Dec 23, 2024
@jcfranco jcfranco requested a review from driskull December 23, 2024 21:41
@@ -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;
Copy link
Member Author

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.

Copy link
Member

@driskull driskull left a 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) {
Copy link
Member

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 👍

Copy link
Member Author

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?

Copy link
Member

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.

@jcfranco jcfranco added the skip visual snapshots Pull requests that do not need visual regression testing. label Dec 23, 2024
@jcfranco jcfranco merged commit 5874d6f into dev Dec 23, 2024
23 checks passed
@jcfranco jcfranco deleted the jcfranco/clear-action-menu-el-on-disconnect branch December 23, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. no changelog entry Use the commit override to avoid a changelog entry skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants