Repository navigation
fix: re-generate items on the hidden or disabled property change - #3027
Conversation
ff195ad to
8543589
Compare
| } | ||
|
|
||
| const observer = new MutationObserver((records) => { | ||
| const hasChangedAttributes = records.some((entry) => { |
There was a problem hiding this comment.
note: I had to add this check because the context-menu has a logic where it ensures the disabled attribute, and if it is already present on the item element, it ends up re-assigned which triggers the Mutation Observer here (reference)
|
Fixing the current issue also revealed another one that I don't have a good workaround for: if you add a new menu item while an ancestor of the menu bar is hidden, the new item won't be properly attached to the DOM. In order to make it work, you will need to cause the menu bar to re-render manually after the ancestor becomes visible. There is no reliable way to pick up on that in the connector as well as no Flow API that would allow detecting the visibility change of an ancestor of a component. As long as there is no API, we cannot fix that issue, so I would go with creating a ticket but not considering it in the scope of the current PR. |
f57d419 to
ec4e173
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
…) (#3032) Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
|
This ticket/PR has been released with Vaadin 23.1.0.alpha3 and is also targeting the upcoming stable 23.1.0 version. |








Description
This PR adds a MutationObserver to the menu bar connector that watches for the
hiddenanddisabledattributes and triggers re-generating the menu bar items if an attribute change occurs.It solves the issue where changing the visibility or disabled state of a menu item wouldn't be applied if an ancestor of the menu bar was hidden at the same time.
Fixes #2134
Depends on #3025
Type of change
Checklist