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

scrollIntoView does not fully reveal item if scroll element's client size and offset size are different #634

Open
2 tasks done
ccblaisdell opened this issue Dec 11, 2023 · 0 comments

Comments

@ccblaisdell
Copy link

Describe the bug

The virtualizer's scrollIntoView method does not fully scroll an item into view at the end of the block if the scroll element's client size and offset size are different. For example if the scroll element has a border or scrollbar.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/tender-tom-z8876k

Steps to reproduce

This grid is forked from the official "Fixed" react example. Keyboard arrow navigation has been added, plus a 10px thick border on the scroll element.

Click onto a grid item to focus it, and then use the right or down arrow keys to navigate past the edge of the scroll container, you will find that the focused item does not get fully scrolled into view, but is partly obscured by the scroll element's border.

Expected behavior

As a user I expected the focused cell to be fully, but just barely, scrolled into view at the edge of the scroll element. Instead, it's partly cropped.

How often does this bug happen?

Every time

Screenshots or Videos

CleanShot.2023-12-11.at.15.30.05.mp4

Platform

macOS, chrome

tanstack-virtual version

3.0.1

TypeScript version

No response

Additional context

In another application I'm working on, the virtualizer does not account for the size of a scrollbar and exhibits the same defect.

This example can be repaired by overriding the virtualizers' scrollRect with the scroll element's clientWidth and clientHeight measurements. You can see this by uncommenting the code at the top of the onFocus handler on the items.

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant