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

[a11y]: File uploader has static id that can cause conflicts #17556

Closed
2 tasks done
parejko opened this issue Sep 23, 2024 · 4 comments · Fixed by #17651
Closed
2 tasks done

[a11y]: File uploader has static id that can cause conflicts #17556

parejko opened this issue Sep 23, 2024 · 4 comments · Fixed by #17651
Labels
component: file-uploader good first issue 👋 Used by GitHub to elevate contribution opportunities hacktoberfest See https://hacktoberfest.com/ package: @carbon/react @carbon/react role: dev 🤖 severity: 2 https://ibm.biz/carbon-severity type: a11y ♿ type: bug 🐛

Comments

@parejko
Copy link

parejko commented Sep 23, 2024

Package

@carbon/react

Browser

Chrome

Operating System

MacOS

Package version

1.66.0

React version

No response

Automated testing tool and ruleset

devtools

Assistive technology

No response

Description

File uploader id are not unique:

  • description has id="description" -> expected more complex id with incremental value like fileuploader-description-1
  • label has id="id1" -> expected more complex id like fileuploader-input-1`

See screenshot
image

File uploader could have ids like ie. Select -

: `select-helper-text-${selectInstanceId}`;

Unique ID tool could have also similar complexity as above.
let lastId = 0;
export default function uniqueId(prefix = 'id') {
lastId++;
return `${prefix}${lastId}`;
}

WCAG 2.1 Violation

No response

Reproduction/example

https://react.carbondesignsystem.com/?path=/docs/components-fileuploader--overview

Steps to reproduce

  1. check html of file uploader in storybook or in app

Suggested Severity

None

Code of Conduct

@tay1orjones
Copy link
Member

Thanks for opening this from our conversation on slack.

I'll add that this specifically is an issue because there may be more than one of these on the page and therefore would have multiple id's of the same value on the page, which isn't allowed.

Ref: #15274

Generally all id's should be procedurally generated with the internal helper built around React.useId() to ensure multiple instances are supported and the values match from server to client, if applicable.

@tay1orjones tay1orjones added severity: 2 https://ibm.biz/carbon-severity good first issue 👋 Used by GitHub to elevate contribution opportunities component: file-uploader hacktoberfest See https://hacktoberfest.com/ package: @carbon/react @carbon/react and removed status: needs triage 🕵️‍♀️ labels Sep 23, 2024
@tay1orjones tay1orjones moved this to ⏱ Backlog in Design System Sep 23, 2024
@tay1orjones tay1orjones changed the title [a11y]: File uploader - generic ids [a11y]: File uploader has static id that can cause conflicts Sep 23, 2024
@Shankar-CodeJunkie
Copy link
Contributor

@tay1orjones : Hope you are doing fine ! . I would like to work on this issue. Can you assign this issue to me ? Thanks

@tay1orjones
Copy link
Member

@Shankar-CodeJunkie Yeah sounds great! We usually rely on comments like yours to indicate work is in progress. Thanks for taking an interest in this one!

@Shankar-CodeJunkie
Copy link
Contributor

Shankar-CodeJunkie commented Oct 3, 2024

@tay1orjones : I have made the required changes and can you please verify the below and tell me, whether this can be sent for your review . I hope for this pull request, the change is only needed on the FileUploader component alone and not on other components like FileUploaderButton

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: file-uploader good first issue 👋 Used by GitHub to elevate contribution opportunities hacktoberfest See https://hacktoberfest.com/ package: @carbon/react @carbon/react role: dev 🤖 severity: 2 https://ibm.biz/carbon-severity type: a11y ♿ type: bug 🐛
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants