-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(DataTable): fix duplicate expanded row id for multiple tables #19416
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
base: main
Are you sure you want to change the base?
fix(DataTable): fix duplicate expanded row id for multiple tables #19416
Conversation
All contributors have signed the DCO. |
I have read the DCO document and I hereby sign the DCO. |
✅ Deploy Preview for v11-carbon-web-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
b364b6e
to
ca49f4d
Compare
Please do not remove checklist items from the pr template. If some do not apply, just |
Thanks for submitting the PR! Since I initially reported the issue, I wanted to point out that the problem isn’t limited to just id attributes—there are also violations related to |
Thanks for the note! I actually had a local fix ready for the specific |
@@ -612,7 +612,7 @@ class DataTable<RowType, ColTypes extends any[]> extends React.Component< | |||
}) => { | |||
return { | |||
...rest, | |||
id: `expanded-row-${row.id}`, | |||
id: `expanded-row-${row.id}-${this.instanceId}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to store this ID in a variable to keep the implementation DRY and ensure consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I’ve updated to use a variable for the expanded row ID.
Hey @Rudra1402 , could you please add the steps to test this PR |
Hello, create 2 DataTables with expandable rows for comparative analysis use case. Run the IBM A11y Checker, you'll notice duplicate id violations. |
Issue:
Changelog
Changed
id
andaria-controls
attributes are set for expanded rows when multiple tables with expandable rows are present.instanceId
to each row’sid
to ensure uniqueness within the DOM.instanceId
to thearia-controls
attribute to correctly associate it with the corresponding rowid
.Testing / Reviewing
Before making changes:
expanded-row-a
. You’ll notice that multiple rows have the sameid
value.After making changes:
instanceId
makes eachid
unique.PR Checklist
As the author of this PR, before marking ready for review, confirm you:
Updated documentation and storybook examplesWrote passing tests that cover this changeMore details can be found in the pull request guide