Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting a row on one DataTable unchecks radio button on another DataTable #2081

Open
bhavers opened this issue Jan 7, 2025 · 1 comment · May be fixed by #2082
Open

Selecting a row on one DataTable unchecks radio button on another DataTable #2081

bhavers opened this issue Jan 7, 2025 · 1 comment · May be fixed by #2082
Assignees
Labels
bug Something isn't working

Comments

@bhavers
Copy link
Contributor

bhavers commented Jan 7, 2025

Problem:

  • Selecting a row in one DataTable will result in unselecting the radio button of a row with the same id of another DataTable on the same page.

Situation:

  • Two DataTables on the same page.
  • DataTables using radio buttons for selection.
  • Both DataTables use the same id property for the rows.

Reproduce issue:

Analysis
See analysis of @theetrain on Discord.

It appears that when radio={true} on the DataTable, the name attribute is set as the row's ID. I think the radio prop ought to accept a string as the desired name, and then its value attribute would be the Row's ID.
In other words, a row with an id abc123 should have a radio input like this:
<input type="radio" name="table-1-row" value="abc123" />
Link to code:

name="select-row-{row.id}"

Workaround:

  • use different id's for DataTables.
@bhavers bhavers changed the title Two DataTables uncheck radio button when using the same id's. Selecting a row on one DataTable unchecks radio button on another DataTable Jan 7, 2025
@metonym metonym self-assigned this Jan 8, 2025
@metonym metonym added the bug Something isn't working label Jan 8, 2025
@metonym
Copy link
Collaborator

metonym commented Jan 8, 2025

Nice catch – thanks for the detailed repro.

I've a fix in #2082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants