Skip to content

refactor: simplify menu-bar observers to reduce update count - #9649

Merged
web-padawan merged 3 commits into
mainfrom
refactor/menu-bar-simplify-observers
Jul 7, 2025
Merged

web-padawan merged 3 commits into
mainfrom
refactor/menu-bar-simplify-observers

Conversation

@web-padawan

Copy link
Copy Markdown
Member

Description

Follow-up to #9618

Previously, we were setting _container after a microtask to delay running observers. This is no longer needed.

  • Updated the menu-bar logic to use updated(), which runs after ready(), instead of individual observers that run before ready(). This way it runs after both _container and _overflow are set, which eliminates the need to define them in static get properties(). As a result we get one update less during an initial render of the component.
  • Changed _hasOverflow to not be a reactive property either, otherwise setting it on resize (e.g. when inside of a split layout on the dev page) triggers update cycle for the component unnecessarily, whereas in fact we only need to set or remove the attribute.
  • Moved two container event listeners to the Lit template instead of adding them manually in the ready() block.

Type of change

  • Refactor.

@web-padawan
web-padawan requested a review from vursen July 7, 2025 07:24

@vursen vursen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring!

Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2025

Copy link
Copy Markdown

@web-padawan
web-padawan merged commit 48809d3 into main Jul 7, 2025
@web-padawan
web-padawan deleted the refactor/menu-bar-simplify-observers branch July 7, 2025 07:49
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.0.0-alpha2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants