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

[EuiDataGrid] Add scroll anchor row option #6070

Merged

Conversation

weltenwort
Copy link
Member

@weltenwort weltenwort commented Jul 22, 2022

🗒️ Summary

This adds a mechanism to the EuiDataGrid to compensate for vertical layout shifts when rows above the currently visible ones change their height. This often happens when the row heights are "auto"-measured and new rows are rendered in the overscan area. By specifying a scrollAnchorRow: 'start', the grid will try to scroll to keep the vertical position of the topmost visible row stable in the viewport. This behavior is opt-in.

closes #6024
extracted from #6028

🎨 Previews

Checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart (no visible changes)
  • A changelog entry exists and is marked appropriately

@weltenwort weltenwort self-assigned this Jul 22, 2022
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6070/

@weltenwort weltenwort marked this pull request as ready for review July 28, 2022 18:54
@weltenwort
Copy link
Member Author

@constancecchen @chandlerprall I'm struggling to find the time to write an example. Would you accept this with just the docs and tests, but without an example for now? 🙈

@weltenwort weltenwort changed the title Add scroll anchor row option [EuiDataGrid] Add scroll anchor row option Aug 1, 2022
@chandlerprall
Copy link
Contributor

@constancecchen @chandlerprall I'm struggling to find the time to write an example. Would you accept this with just the docs and tests, but without an example for now? 🙈

I'll get a pass at this PR tomorrow (U.S. time), but don't worry about an example - we'll either accept as-is or will put an example together for ya

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

This works really well! I played with a number of configurations locally and everything Just Worked™️

I've added this to the virtualization example, keeping the viewport anchored when toggling between the width options.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6070/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6070/

weltenwort and others added 2 commits August 3, 2022 11:10
…ample.js

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
@weltenwort
Copy link
Member Author

weltenwort commented Aug 3, 2022

@constancecchen @chandlerprall Thanks for the thorough review and contributing tests and an example ❤️

edit: not to forget correcting all by grammar mistakes

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_6070/

@weltenwort weltenwort merged commit e8dcfb2 into elastic:main Aug 3, 2022
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.

[EuiDataGrid] Reduce layout shift when row heights are measured automatically
4 participants