-
Notifications
You must be signed in to change notification settings - Fork 87
fix: update horizontal scroll position on data change #10192
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: update horizontal scroll position on data change #10192
Conversation
| // Updating data can change the visibility of the scroll bar. Therefore, the scroll position | ||
| // has to be recalculated. | ||
| requestAnimationFrame(() => { | ||
| this.__updateHorizontalScrollPosition(); |
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.
We already have a resize observer on the table element:
web-components/packages/grid/src/vaadin-grid-mixin.js
Lines 266 to 271 in 587c730
| new ResizeObserver(() => | |
| setTimeout(() => { | |
| this.__updateColumnsBodyContentHidden(); | |
| }), | |
| ).observe(this.$.table); | |
Adding the scroll position update there also seems to work and might cover other scenarios as well?
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.
Thanks for the suggestion. I hadn't noticed the table resize observer. Updated the fix to call the update on table resize. Also updated the test and simplified it a little bit.
|
* fix: update horizontal scroll position on data change * refactor: update scroll position on table resize
* fix: update horizontal scroll position on data change * refactor: update scroll position on table resize
|
This ticket/PR has been released with Vaadin 25.0.0-alpha12. |



Description
When the data changes but there is no resize or scroll, the column widths are not recalculated with a new scroll position. On Windows, this leads to frozen-to-end columns not properly moved to the end, displaying data from other columns where the scroll bar was previously located.
This PR updates horizontal scroll position when the data changes. This makes sure that the frozen-to-end columns are always located at the end, even when there is no resize or scroll.
Fixes vaadin/flow-components#6666.
Type of change
Checklist