iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
615 stars 210 forks source link

Table: selected rows don't change location when column is sorted #2265

Closed MargaritaKartaviciute closed 1 year ago

MargaritaKartaviciute commented 3 years ago

Describe the bug Media1

When rows selected in table and table sorted by column, previously selected elements don't change their location. After table sorting it seems that completely different elements was selected.

To Reproduce Steps to reproduce the behavior:

  1. SimpleTableDataProvider should have ColumnDescription with property sortable set to true:
    
    const columns: ColumnDescription[] = [];

columns.push({ key: "current_class", label: "Original class", sortable: true }); columns.push({ key: "max_class", label: "Predicted class", sortable: true });

const dataProvider = new SimpleTableDataProvider(columns);

2. Create Table with this dataProvider:

<Table dataProvider={_getDataProvider()} />


3. Try to select element and sort table by column
4. See issue

**Expected behavior**
When some rows are selected and table is sorted by column, elements selection will be changed according sorted elements.

**Desktop:**

- @bentley/ui-components version [^2.14.0]

<!--

If you can also contribute a fix, we'd absolutely appreciate it!

Check out the contributor guide to get started:

https://github.com/imodeljs/imodeljs/blob/master/CONTRIBUTING.md

Just let us know you're working on it and we'd be happy to provide advice and feedback.

-->
NancyMcCallB commented 3 years ago

Thanks for reporting this, Margarita. I'll look into this and get back to you.

lpasselin commented 2 years ago

@NancyMcCallB Any progress on this issue?

NancyMcCallB commented 2 years ago

I apologize! I thought I had responded to you back in September.

The current implementation of the Table component tracks only the current row indices. Because the component is built on the react-data-grid, which is not well-maintained, we've decided to deprecate it in the next release and develop a replacement in our general-purpose React component library iTwinUI-react. To future-proof your code, it would be a good idea to look at that Table component rather than writing a custom data provider for this Table component. We'll be replacing our uses of Table internally with the iTwinUi implementation, as well.

raplemie commented 1 year ago

The Table component have now been completely removed due to lack of support of the underlying components. The @itwin/itwinui-react package now offer a completely new table component which should be used instead this.

Closing this issue. Thanks.