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

[BUG] Vertical scroll doesn't work properly if horizontal scroll is present and moved #609

Closed
maciejregula opened this issue Mar 15, 2022 · 15 comments
Labels

Comments

@maciejregula
Copy link

maciejregula commented Mar 15, 2022

Hello,

In the TableVirtuoso component, vertical scroll doesn't work properly if horizontal scroll exists and is moved to the right.
The bug is present even on the demo page.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the https://virtuoso.dev/table-fixed-columns/
  2. Move the horizontal scrollbar to the right.
  3. Move vertical scrollbar to the bottom - you will notice that scroll doesn't work properly

Expected behavior
Vertical scrollbar should properly scroll according to the current mouse position.

@maciejregula maciejregula added the bug Something isn't working label Mar 15, 2022
@maciejregula maciejregula changed the title [BUG] Vertical scroll not working properly if horizontal scroll appers [BUG] Vertical scroll doesn't work properly if horizontal scroll is present and moved Mar 15, 2022
@petyosi
Copy link
Owner

petyosi commented Mar 15, 2022

What browser/OS? Can you record a video?

@maciejregula
Copy link
Author

react-virtuoso.mp4

My OS: Chrome 99, windows 10 pro

@maciejregula
Copy link
Author

maciejregula commented Mar 15, 2022

The issue doesn't occur in Firefox. However, I can confirm that it occurs in Chrome and Edge.
I also noticed when you scroll very slowly, it works ok.

@fatton139
Copy link

fatton139 commented Apr 6, 2022

Ran into this issue as well on Chrome.

I had a look at the call stack for when the scroll event gets is triggered on the virtuoso-scroller and it traces back to the event handler in useScrollTop.ts.

Not sure why the event is continuously fired.

Happy to try to make a PR, but currently I don't understand the codebase enough to know where to proceed.

@shinenic
Copy link

shinenic commented May 6, 2022

Got this issue as well on my Chrome as well, but it works on my Safari.

Screen.Recording.2022-05-06.at.11.47.00.PM.mov

Browser: Chrome Version 100.0.4896.127 (Official Build) (arm64)
Mac OS: 12.3.1

@Tirzono
Copy link

Tirzono commented May 11, 2022

I noticed this becomes an issue when the first column is not in view anymore. So with the sticky column example it only becomes a problem if you scroll horizontally that far that even if the column would not be sticky, it would be out of view.

Maybe it is something that looks at the first column and because it's out of view it becomes an issue?

@petyosi do you know any part of the code that looks at the first column size or something like that? I tried to look to find something myself but I have a hard time finding where I need to be. If you have some ideas where to look at then I am happy to make a PR.

@Tirzono
Copy link

Tirzono commented May 17, 2022

After debugging for a while I noticed that it isn't necessarily an issue with the first column being the issue but it has more to do with the fact that the height and widths of the rows/columns are changing while scrolling and the reason why we saw this issue when we scrolled that far that the first column was not visible is because of the fact that the first column in the examples had a fixed width and the others had a dynamic width.

In an example where all the columns have a fixed width scrolling works normally:

https://codesandbox.io/s/sandpack-project-forked-4lf9o5?file=/App.js

So a workaround for now would be to set a fixed width for each column.

@tklg
Copy link

tklg commented May 17, 2022

The issue is still present in the example with all fixed width columns:

2022-05-17.09-11-10.mp4

@petyosi
Copy link
Owner

petyosi commented May 24, 2022

Here's a workaround for the problem, which I am not exactly happy with. https://codesandbox.io/s/sandpack-project-forked-pg6te6?file=/App.js

The problem seems to be related that the filler row td needs to span the entire table. I could not find a way to span it automatically, and counting cells seems like a brittle solution.

To ensure that we don't conflate two separate problems: since the table is virtualized, it's highly recommended to:

  • set the layout to fixed
  • set explicitly the width of each column

Otherwise, the width of the columns will fluctuate when scrolling around, based on the content in it. There's no magic that can guess what the width of the column be since the content is not available.

If anyone has a better idea on how to make a filler row - please share.

@mrfrigerio
Copy link

I don't thing that this solves the problem. I'm using fixed layout and fixed width columns but i'm facing the same behavior.
Automatic scrolling down indefinitely.

@petyosi
Copy link
Owner

petyosi commented Jul 8, 2022

@mrfrigerio Reproduce the problem using the workaround from my previous comment in a sandbox and paste a link here.

@mrfrigerio
Copy link

mrfrigerio commented Jul 10, 2022

https://codesandbox.io/s/sandpack-project-forked-pg6te6?file=/App.js

Sorry @petyosi , my bad. I didn't see the custom FillerRow. Implementing that way works like a charm.

Thank you

@ivanjoz
Copy link

ivanjoz commented Jun 9, 2023

I was experiencing the same problem. Solved by this css rule

style={{ overflowAnchor: "none" }} in the overflowing div. It has to do with the browser's scroll anchoring behavior

I found the solution here https://github.com/TanStack/virtual/issues/426
And also here https://stackoverflow.com/questions/42958463/stop-automatic-scrolling-on-page-content-change

@petyosi
Copy link
Owner

petyosi commented Jun 10, 2023

@ivanjoz Thanks for sharing that, I incorporated the fix.

@github-actions
Copy link

🎉 This issue has been resolved in version 4.3.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants