carbon icon indicating copy to clipboard operation
carbon copied to clipboard

carbon-components-react: When using onSelect in DataTable, changes to isSelected are ignored

Open dfoverdx opened this issue 4 years ago • 1 comments

carbon-components-react: When using onSelect in DataTable, changes to isSelected are ignored

What package(s) are you using?

  • [ ] carbon-components
  • [x] carbon-components-react

Detailed description

Describe in detail the issue you're having.

If I set the onSelect property of the DataTable's TableSelectRow, and set the isSelected on my rows, the DataTable overrides any changes. On initial render, it works. I have only tested this on the radio selection version.

What did you expect to happen? What happened instead?

When I click on a row's radio button, the newly selected row should be selected. Instead, the original row was selected.

What browser are you working in?

Chrome/78.0.3904.99

What version of the Carbon Design System are you using?

carbon-components: 10.20.0 carbon-components-react: 7.20.0

Please create a reduced test case in CodeSandbox

https://codesandbox.io/s/summer-dust-xnc0y?file=/src/index.js

dfoverdx avatar Dec 18 '20 18:12 dfoverdx

most likely you would need to implement this with a custom state manager, meaning you would be implementing that logic using Carbon table primitives like Table, TableHead, TableRow, etc. rather than using the built in state manager in DataTable, if that makes sense

emyarod avatar Jan 21 '21 19:01 emyarod