Skip to content

fix(a11y): give the file upload button an accessible name - #3902

Merged
Chartman123 merged 2 commits into
nextcloud:mainfrom
v01dst:fix/3839-file-upload-button-name
Nov 18, 2026
Merged

Chartman123 merged 2 commits into
nextcloud:mainfrom
v01dst:fix/3839-file-upload-button-name

Conversation

@v01dst

@v01dst v01dst commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The upload button of a file question carries only an icon (IconUpload /
IconUploadMultiple). A screen reader announces it as "button" and nothing
tells the user what it does, which fails WCAG 4.1.2 Name, Role, Value. axe
reports it as button-name (critical).

The visible text "Add new file as answer" is not a fix here: it belongs to the
<label> around the hidden <input type="file">, so it never reaches the
button.

In the editor the button is disabled as well, so it shows up there as an
unnamed, disabled button.

Solution

The button gets an aria-label:

  • "Upload a file" when the question takes a single file
  • "Upload files" when more than one file is allowed

The label follows maxAllowedFilesCount, the same setting that picks the
icon, so the two never disagree.

<NcButton
    :aria-label="uploadButtonLabel"
    :disabled="!readOnly || values.length >= maxAllowedFilesCount"
    variant="tertiary-no-background"
    @click="toggleFileInput">

Test

playwright/e2e/a11y-question-inputs.spec.ts gains a case that opens a form
with a file question, switches to the view mode and looks for the button by
its accessible name:

const question = page.getByRole('listitem', { name: /Question number 1/ })
await expect(
    question.getByRole('button', { name: 'Upload a file' }),
).toBeVisible()

Looking the button up by role and name is the same check a screen reader
does, so the test fails without the fix.

Testing

  • npx prettier --check on both changed files: passes
  • npx eslint on both changed files: passes
  • npm run typecheck: no new errors. The project has 113 type errors on
    main already (QuestionDate.vue, QuestionMultiple.vue,
    QuestionRanking.vue and others); the count and the file list are
    unchanged with this branch applied.

The Playwright suite needs a running Nextcloud server, so it could not be
executed here.

Fixes #3839

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

An AI coding agent (OpenCode, MiniMax-M3.1-Flash) drafted the component
change and the Playwright case. I read the diff line by line, ran prettier,
eslint and the type check, and wrote the text above myself.

@Chartman123

Chartman123 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

@v01dst Thanks for your contribution. Please also add the AI block back to the PR description if you used AI for this.

DCO also doesn't pass as you didn't sign-off your commit

@v01dst
v01dst force-pushed the fix/3839-file-upload-button-name branch from 86c1d2f to 428c38c Compare November 16, 2026 16:21
@AndyScherzinger AndyScherzinger added bug Something isn't working 3. to review Waiting for reviews a11y related to accessibility labels Nov 16, 2026
The upload button of a file question only holds an icon, so a screen reader
announces it as "button" without saying what it does. axe reports it as
`button-name`, which fails WCAG 4.1.2.

The button now gets an `aria-label`. It says "Upload a file" for a question
that takes one file and "Upload files" when more than one file is allowed.

The visible text "Add new file as answer" stays where it is: it belongs to the
label of the hidden file input, not to the button.

Fixes nextcloud#3839

Signed-off-by: v01dst <v01dst@users.noreply.github.com>
Assisted-by: OpenCode:MiniMax-M3.1-Flash
@v01dst
v01dst force-pushed the fix/3839-file-upload-button-name branch from 428c38c to 3523117 Compare November 17, 2026 15:33
@v01dst

v01dst commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the hint. The commit is signed off now, and the AI block is back in the description. The commit also carries an Assisted-by trailer, as the AI policy asks for.

If anything else is missing, please tell me.

@Chartman123

Copy link
Copy Markdown
Collaborator

If anything else is missing, please tell me.

The requested changes in QuestionFile.vue regarding the translations are still pending :)

@AndyScherzinger
AndyScherzinger marked this pull request as draft November 18, 2026 14:40
The name of the upload button now comes from n(), so each language gets
the plural forms it needs for the number of files a question allows.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@Chartman123
Chartman123 marked this pull request as ready for review November 18, 2026 15:21
@Chartman123
Chartman123 self-requested a review November 18, 2026 15:22
@Chartman123

Copy link
Copy Markdown
Collaborator

/backport to stable5.4

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Nov 18, 2026
@Chartman123
Chartman123 merged commit 16b25b0 into nextcloud:main Nov 18, 2026
43 checks passed
@backportbot backportbot Bot removed the backport-request Pending backport by the backport-bot label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews a11y related to accessibility bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File question: the upload button has no accessible name

3 participants