carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.59k stars 1.76k forks source link

[Bug] DataTable with radio selection breaks when there are 2+ radio DataTables in DOM #16843

Open FFahrenheit opened 1 week ago

FFahrenheit commented 1 week ago

Package

@carbon/react

Browser

Chrome, Safari, Firefox

Package version

v1.60.0

React version

v18.2.0

Description

The DataTable radio selection breaks if there are two or more <DataTable> with radio selection property enabled. The selection does not work in any of the two tables, selecting random rows between the tables in DOM

Reproduction/example

https://stackblitz.com/edit/github-rjvrvh?file=package.json

Steps to reproduce

  1. Add two (or more) <DataTable> with radio option. Happens even with different data and IDs
  2. Select a row in the first table
  3. Select a row in other table <- from this moment forward none of the tables selection works properly

Suggested Severity

None

Application/PAL

No response

Code of Conduct

tay1orjones commented 1 week ago

@FFahrenheit I found this from a related PR:

If a user has multiple radio tables, they would just need to pass in their own name prop to TableSelectRow after the getSelectionProps

It does fix it, here's an example, though I wonder if we could fix this without reintroducing the bug that that PR fixed.

FFahrenheit commented 1 week ago

Hi @tay1orjones that fixed the issue for me! Thank you :)

image