question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataTable with Selection: fails to update selections when rows update

See original GitHub issue

What package(s) are you using?

  • carbon-components v10.12.0
  • carbon-components-react v7.12.0

Detailed description

Describe in detail the issue you’re having.

When rendering a DataTable with a selection column, the rows’ selection cannot be updated after the initial render.

This seems to be due to the override of the isSelected field from the existing state’s value if the row’s ID already exists in the table.

https://github.com/carbon-design-system/carbon/blob/942c80dc02be23a8ce65688d09dd619209fd1861/packages/react/src/components/DataTable/tools/normalize.js#L44

Is this issue related to a specific component?

DataTable with Selection.

What did you expect to happen? What happened instead? What would you like to see changed?

The DataTable should react to the input’s data: if the rows’ isSelected property is updated and the Table is rerendered, the table should not override the isSelected with a possibly stale value.

What browser are you working in?

Google Chrome

What offering/product do you work on? Any pressing ship or release dates we should be aware of?

The product is to be released at the end of June 2020.

Steps to reproduce the issue

https://codesandbox.io/s/nifty-germain-2emx2?file=/src/index.js

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:17
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
gicommented, Jun 12, 2020

However, I have to ask: Why support (mutable) selection if there isn’t an easy, supported way to communicate that selection out of the table’s internal state?

https://github.com/carbon-design-system/carbon/issues/6260

1reaction
rwibmcommented, Oct 24, 2022

Is there still no fix planned for this? This bug still affects Carbon v11 and makes the selection feature in data tables somewhat moot when you can’t easily access the internal selection state either.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent select event from firing if selection has not changed
row ('.selected').data(); // a*) I re-collect selections because they may have changed since click // 2) update the {selection token} with ...
Read more >
Selected_row_ids not updating when selected_rows is changed
A couple of interesting things: If you click on the select all button, then un-select a row, then the selected_row_ids is updated correctly....
Read more >
DataTable does not re-draw after updating rows - Stack Overflow
DataTable (); //Iterate over selected rows var rowData = table.rows({ selected: true }).every(function() { //For every selected row, update ...
Read more >
DataTable - need to update components after row selection
When I make some row selections nothing happens. If I hit the Delete button, the confirmation dialog pops up - if I hit...
Read more >
DataTables Extensions
The FixedColumns extension does not work well with row selection: when you select rows in the fixed columns, the rows in other columns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found