fix(core): include selected filenames in FileInput trigger name#3989
Open
bhamodi wants to merge 1 commit into
Open
fix(core): include selected filenames in FileInput trigger name#3989bhamodi wants to merge 1 commit into
bhamodi wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
FileInputtrigger is arole="button"div that setsaria-label={label}(FileInput.tsx:737). Per accname computation,aria-labelsuppresses the element's child content from the accessible name -- and the selected filenames render as children (fileNamesin bothrenderDropzoneContentandrenderCompactContent). So a screen-reader user who tabs back to the control after selecting files hears only the field label, with no way to tell what (if anything) is attached. The one-time pick announcement from #3447 (7d90206,useAnnounce) is transient by design; the persistent name never reflected the selection.This composes the filenames into the label:
aria-label={hasFiles && fileNames ?${label}, ${fileNames}: label}. With files selected the trigger reads e.g. "Document, report.pdf"; with none it stays exactly the label. It reuses the existinghasFiles/fileNamesderivations (already comma-joined for multiple files) -- no renderer restructuring, no new strings.Prior FileInput a11y work: 7dfac3a (#3404, forms-6) moved
aria-describedby/required/invalidonto this same focusable trigger, and 7d90206 (#3447, forms-17) added the pick-time live-region announcement. This fills the remaining gap: the persistent accessible name.Changes
FileInput/FileInput.tsx: compose the trigger'saria-labelfrom the label plusfileNameswhen files are selected (one attribute; falls back to plainlabelwhen empty), with a comment explaining why child content alone is not enough.FileInput/FileInput.test.tsx: newtrigger accessible namedescribe block (4 tests) -- single file included in the name, multiple files all present (comma-joined), no files means the name is exactly the label, and dropzone mode covered..changeset/fileinput-trigger-name.md: patch changeset.Test plan
node_modules/.bin/vitest run --root . packages/core/src/FileInput-- 53 pass (was 49). The 3 positive new tests (single, multiple, dropzone) fail pre-fix with the trigger named only "Document"/"Files"/"Upload"; the label-only test guards against regression in the empty state.node_modules/.bin/vitest run --root . packages/core-- 4585 pass, 203 files (full core suite).node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit-- clean.node_modules/.bin/eslint+prettier --checkon changed files -- clean.Notes
Found during a broader a11y audit of core components; scoped to one fix per PR.