KEMBAR78
refactor: avoid forced style recalculation on scroll by vursen · Pull Request #10150 · vaadin/web-components · GitHub
Skip to content

Conversation

@vursen
Copy link
Contributor

@vursen vursen commented Sep 11, 2025

Description

This PR updates the virtualizer's scroll handler to read from the cached _scrollPosition instead of directly from the element's scrollTop since that one can trigger a forced style recalculation if accessed immediately after style writes.

Before After
Screenshot 2025-09-11 at 9 56 21 Screenshot 2025-09-11 at 9 54 07

Part of vaadin/flow-components#7985

Type of change

  • Refactor

@sonarqubecloud
Copy link

);
}

this.__previousScrollTop = this._scrollTop;
Copy link
Contributor Author

@vursen vursen Sep 11, 2025

Choose a reason for hiding this comment

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

_scrollTop reads the actual scrollTop value from the DOM, which can force a style recalculation if done immediately after style writes.

@vursen vursen changed the title refactor: avoid unnecessary style recalculation refactor: avoid forced style recalculation on scroll Sep 11, 2025
@vursen vursen requested review from sissbruecker, tomivirkki and ugur-vaadin and removed request for tomivirkki September 11, 2025 06:08
@vursen vursen merged commit f9d5f09 into main Sep 11, 2025
9 checks passed
@vursen vursen deleted the avoid-style-recalculation branch September 11, 2025 09:46
@vaadin-bot
Copy link
Collaborator

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

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