Skip to content

frontend: DropZoneBox: Remove role=button from label element#4647

Draft
Vaishnav-Dhaval wants to merge 1 commit intokubernetes-sigs:mainfrom
Vaishnav-Dhaval:fix/issue-4612
Draft

frontend: DropZoneBox: Remove role=button from label element#4647
Vaishnav-Dhaval wants to merge 1 commit intokubernetes-sigs:mainfrom
Vaishnav-Dhaval:fix/issue-4612

Conversation

@Vaishnav-Dhaval
Copy link
Contributor

Summary

This PR fixes an accessibility violation in the DropZoneBox component and its stories where a <label> element was incorrectly assigned a role="button" attribute.

Related Issue

Fixes #4612

Changes

  • Updated frontend/src/components/common/Resource/UploadDialog.tsx to use a React ref for triggering the hidden file input instead of relying on Material UI's component="label" on the Button.
  • Updated frontend/src/components/common/DropZoneBox.stories.tsx to remove the unnecessary component="label" from the UploadFiles story.
  • Updated Storybook snapshots in frontend/src/components/common/__snapshots__/DropZoneBox.UploadFiles.stories.storyshot to reflect the change from a <label> element to a semantic <button> element.

Steps to Test

  1. Run the Storybook tests for DropZoneBox:
    cd frontend
    npx vitest src/storybook.test.tsx -t DropZoneBox
  2. Manually verify the "Create new Project from YAML" dialog:
    • Navigate to the "Create from YAML" section (or open any dialog using UploadDialog).
    • Inspect the "Select File" button using browser dev tools.
    • Verify that the element is a <button> (and not a <label> with role="button") and that clicking it still opens the file picker.

Screenshots (if applicable)

N/A (Accessibility change)

Notes for the Reviewer

  • The change from component="label" to a manual ref is a standard way to handle file inputs in React while maintaining accessibility compliance (avoiding the ARIA allowed role violation).

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 8, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Vaishnav-Dhaval
Once this PR has been reviewed and has the lgtm label, please assign yolossn for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 8, 2026
@illume illume requested a review from Copilot February 8, 2026 11:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an accessibility violation in the DropZoneBox usage by removing the incorrect role="button" behavior caused by rendering a MUI Button as a <label>, ensuring the UI uses a semantic <button> element instead.

Changes:

  • Updated UploadDialog to trigger the hidden file input via a React ref instead of component="label" on the MUI Button.
  • Updated the DropZoneBox Storybook story to render a semantic <button> (no component="label").
  • Updated Storybook snapshots to reflect the DOM change from <label role="button"> to <button type="button">.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
frontend/src/components/common/Resource/UploadDialog.tsx Replaces label-based file input triggering with a ref-driven click on a hidden <input type="file">.
frontend/src/components/common/DropZoneBox.stories.tsx Removes component="label" so the story renders a proper <button>.
frontend/src/components/common/snapshots/DropZoneBox.UploadFiles.stories.storyshot Snapshot update reflecting <label role="button"><button type="button">.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Vaishnav-Dhaval Vaishnav-Dhaval force-pushed the fix/issue-4612 branch 2 times, most recently from b487183 to 26dcd13 Compare February 8, 2026 13:41
@illume illume added the a11y Accessibility related issues label Feb 8, 2026
@illume illume requested a review from vyncent-t February 8, 2026 14:42
@illume
Copy link
Contributor

illume commented Feb 8, 2026

Thanks for that change.

Can you please ask in the headlamp kubernetes slack channel for someone else to review and test this?

@Champbreed
Copy link

Nice work on the refactor in UploadDialog.tsx! The a11y fix and the useRef implementation look solid.

Two minor observations for the final polish:

  • Storybook Interaction: In DropZoneBox.stories.tsx, removing component="label" means the button in the preview is now non-interactive. It would be best to add a mock onClick action (e.g., using @storybook/addon-actions) so developers can still verify the interaction in the Actions panel.
  • Focus Management: Did you test if the focus returns to the "Select File" button after the file picker is closed? Ensuring focus restoration is essential to round out this a11y improvement for keyboard users.

@illume
Copy link
Contributor

illume commented Feb 11, 2026

Thanks for the review @Champbreed

@Vaishnav-Dhaval can you please reply to the review questions?

@illume
Copy link
Contributor

illume commented Feb 14, 2026

hey hey.

I'll mark this as draft for now to make it easier on reviewers. If you want to continue it, please mark it as ready to review when you've pushed changes.

@illume illume marked this pull request as draft February 14, 2026 14:02
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a11y Accessibility related issues cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

4 participants