-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[data grid] scrollToIndexes not working properly when getRowHeight set to auto
#12242
Comments
This comment was marked as resolved.
This comment was marked as resolved.
auto
auto
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Hey @michelengelen! No worries about the late reply, hope you're feeling better now. Thanks for confirming the bug and providing an example. I'll take a look at it. |
Hi @michelengelen , I encountered the same issue with the apiRef.current.scroll({ top: parseInt(storedPosition) }); method. Is this also a bug? please check following code https://stackblitz.com/edit/mui-mui-x-ddszck?file=src%2Fdemo.tsx |
Hi @swati-kore, could you please put your code in a runnable code example such as this one: https://stackblitz.com/fork/github/mui/mui-x/tree/master/bug-reproductions/x-data-grid And edit your comments to avoid pasting large snippets of code, it makes the issue easier to understand if we can avoid scrolling around so much. Thanks! |
Hi @romgrk @michelengelen Here is runnable code the https://stackblitz.com/edit/mui-mui-x-ddszck?file=src%2Fdemo.tsx Thank you! |
It might have something to do with virtualization. If you perform the scroll action twice: React.useEffect(() => {
setTimeout(() => {
apiRef?.current?.scrollToIndexes({
rowIndex: 50,
});
}, 1000);
setTimeout(() => {
apiRef?.current?.scrollToIndexes({
rowIndex: 50,
});
}, 2000);
}, [apiRef]); with a delay it works. Or if you have a button that scrolls to a certain index and you push it twice. @romgrk do you have any idea if we can even fix this? |
It's currently not possible to jump to an index if the rows have unknown heights, the rows need to be rendered to the DOM to be measured. On your side, you could try to get proper row measurements with something like the I think maybe we could add some logic to keep the view sticked to a row when we update row heights after they've been rendered/measured properly. The scrollbar would update but the view could be stable. @mui/xgrid Is this a feature we'd want to implement? |
Let's wait for upvotes on this issue. |
I'm also hitting this with the upgrade to v7 and it's a big show-stopper for us. We have variable height rows. Scrolling from the bottom of the grid is also (still) a major problem, doesn't work well with height of 'auto'. |
This issue should also exist in v6. Do you have an example that shows a regression? |
Yes, it is still an issue in v6, however, we were able to work around it by calling the The user is stuck at the bottom of the grid unable to scroll up. I just wasted two days trying to work around the issue and finally reverted the upgrade today. I will have to find time to come up with a reproducible example I can share, obviously not able to share production code here. My main point in commenting is due to the comment above about waiting for upvotes before doing anything about it. I wanted to express that for us it is a complete show stopper and so would encourage the team to spend time on fixing the issue at least with the reproducible examples documented so far. |
The core issue with this problem is that it will require to render to the DOM every row that needs to be measured (every
If you can get us a reproduction we'll look into that. |
You may be right in what it would require to fix this, however, this is functionality that is advertised as part of this component. We are paying a license fee to use this component, but we are unable to do so, so we're basically paying for nothing right now. This should be built in and either a flag prop exposed to use this functionality, or this should be prevented and documented well that this functionality is not available. As of now, this is considered a bug on a piece of software that we have purchased that is a major show-stopper for us. I don't know what has changed between v6 and v7 to make the problem so much worse, but whatever it is, the grid is useless to us right now. A major use case for us is to have a selected row coming from the server, so we must be able to load the grid and scroll to that selected row. To dictate that the grid rows must be a fixed height is not a solution our clients can accept. We must have the documented capabilities of using 'auto' row heights, virtualization (we deal with very large datasets in our grids) and the ability to scroll to a given index. |
@jbogedahl-st I understand your frustration but everything has its limits when it comes to making something both performant and usable for as wide a variety of cases as possible. When it comes to what has changed between v6 and v7 we made a conscious decision to focus on the general performance of the grid and thus update the virtualization engine.
The grid has many functionalities and because of that combining multiple features together might result in unexpected behaviors. We do try and test as many scenarios as possible but I think that you can agree that not everything can be covered. That's why we rely on people reporting issues so we can fix those scenarios and cover them with tests so we can be sure that the issue does not resurface. Lastly, you probably also use a variety of other features of the grid so I don't think you are paying for nothing. I hope I was able to ease your frustration. |
I think there's two issues here, the jumps and the height estimation for |
I have tried to understand how the workaround of calling
Also because I was curious AG Grid: https://codesandbox.io/s/auto-row-height-forked-2svp37?file=/src/index.js. It looks like we are missing a reproduction to understand how upgrading to v7 creates an issue. On the root level problem, it's not clear to me that scrollToIndexes() should work with a single API call when we have On the right end-user workaround, maybe we need an API to get the scroll of a given index, say Now, pooling isn't so great. We could also turn this into an event API. We used to have |
@DanailH @romgrk @oliviertassinari - here is a short screen recording of what I'm hitting with v7.5.0 of the data grid. I am still working on creating a simple reproducible of the middle panel. Reproducing the scrollToIndexes() problem is easy, any grid with virtualization and 'auto' row heights hits the problem of not scrolling to the correct item. I'm still trying to pull all the relevant code together to show the other issues as well in a simple example on codesandbox. In the meantime, here is what I'm seeing.. In this video I have a dataset of only 83 records, so it's not even that big. But for the point of illustration, I have virtualization enabled with 'auto' row heights. Here are the steps of what I'm doing:
Video.6-21.at.8.41.webm |
@DanailH @romgrk @oliviertassinari Here is a codesandbox reproducible example. I tried to strip a bunch of the customization and cruft out, but there's still quite a bit there to sift through. If I have time I will try to go back in and whittle it down, in the meantime you can see all problems happening in this example. Choppy, slow, initial load; scrolling to the bottom instead of to the selected row, unable to scroll up smoothly once in this state, etc. https://codesandbox.io/p/sandbox/interesting-swartz-f5tfk7?file=%2Fsrc%2FDataTable.tsx%3A318%2C1 |
Steps to reproduce
Reproduction: https://stackblitz.com/edit/mui-mui-x-nughf3?file=src%2Fdemo.tsx
Screen.Recording.2024-06-21.at.13.03.11.mov
Current behavior
apiRef?.current?.scrollToIndexes is not working in case of Step 3 but working for step 4
Expected behavior
apiRef?.current?.scrollToIndexes should work properly for both step 3 and step 4
Context
I want to scroll to a particular row index even when row text is wrapped or unwrapped
Your environment
Search keywords: scrollToIndexes, data grid, auto row height
The text was updated successfully, but these errors were encountered: