material-react-table icon indicating copy to clipboard operation
material-react-table copied to clipboard

Row ordering with row virtualization

Open RubiCom001 opened this issue 1 year ago • 2 comments

material-react-table version

2.13.1

react & react-dom versions

your own example, so go figure :)

Describe the bug and the steps to reproduce it

I'm using row virtualization and drag and drop between two tables. I can also filter with global search(separate for each table). Once the number of rows is low enough so it fits the height of a table(vertical scrollbar dissapears), when you try to drag a row, it gives an error "Cannot read properties of undefined (reading 'index')". The easiest to reproduce is to use official storybook examples, namely the "Row Ordering With Row Virtualization":

  1. open this example: https://www.material-react-table.dev/?path=/story/features-row-ordering-examples--row-ordering-with-row-virtualization
  2. in the table from example, use global search and enter "delo" . It should filter rows enough so they all fit and vertical scrollbar dissapeares.
  3. try to drag any row image

I think it doesn't make any real life use for a single table to search/filter and order rows at the same time, but it makes sense when you want to filter and drag a row onto another table on the same "form".

I have found similar issue on tanstack table issues, if that helps, but I'm not sure how to try that fix on MRT table: https://github.com/TanStack/table/issues/5689

However, I think, the proper fix, would be if "the code" would check if virtualization is enabled AND actually working, same logic as vertical scrollbar hide/show. Maybe we could simply use vertical scroll somehow here, "if virtualization is enabled and vertical scrollabr is on.... image

Minimal, Reproducible Example - (Optional, but Recommended)

https://www.material-react-table.dev/?path=/story/features-row-ordering-examples--row-ordering-with-row-virtualization

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

Terms

  • [X] I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

RubiCom001 avatar Aug 18 '24 21:08 RubiCom001

I'm posting this because I'm experiencing something similar.

image

I think your code in #178 is referencing undefined in the absence of “row”.

I deleted the count code in rowVirtualizerOptions and it works fine. image

I've done a lot of testing, and I think it's because there's a mismatch between the count in the virtual and the actual row count.

9utty avatar Aug 21 '24 09:08 9utty

Feel free to make a PR then

KevinVandy avatar Aug 21 '24 13:08 KevinVandy