From 35231177f31bdcceca6c414149e4f879757b3dad Mon Sep 17 00:00:00 2001 From: v01dst Date: Mon, 16 Nov 2026 14:56:34 +0200 Subject: [PATCH] fix(a11y): give the file upload button an accessible name 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 #3839 Signed-off-by: v01dst Assisted-by: OpenCode:MiniMax-M3.1-Flash --- playwright/e2e/a11y-question-inputs.spec.ts | 21 +++++++++++++++++++++ src/components/Questions/QuestionFile.vue | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index f95b25ee3..c32bc14f1 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -255,6 +255,27 @@ test.describe('Accessibility: aria attributes on question inputs', () => { await expect(page.locator('#q1_desc')).toContainText('Upload your file') }) + test('File question upload button has an accessible name', async ({ + appNavigation, + form, + topBar, + page, + }) => { + await appNavigation.clickNewForm() + await form.fillTitle('Test form') + + await form.addQuestion(QuestionType.File) + const questions = await form.getQuestions() + await questions[0].fillTitle('My file question') + + await topBar.toggleView(FormsView.View) + + const question = page.getByRole('listitem', { name: /Question number 1/ }) + await expect( + question.getByRole('button', { name: 'Upload a file' }), + ).toBeVisible() + }) + test('Color question with description has aria-labelledby and aria-describedby', async ({ appNavigation, form, diff --git a/src/components/Questions/QuestionFile.vue b/src/components/Questions/QuestionFile.vue index 2f39ef537..847eb40b9 100644 --- a/src/components/Questions/QuestionFile.vue +++ b/src/components/Questions/QuestionFile.vue @@ -134,6 +134,7 @@ @input="onFileInput" /> (() => { + return maxAllowedFilesCount.value > 1 + ? t('forms', 'Upload files') + : t('forms', 'Upload a file') + }) + const allowedFileExtensions = computed(() => { return extraSettings.value.allowedFileExtensions ?? [] }) @@ -532,6 +539,7 @@ export default defineComponent({ availableUnits, uploadedFiles, maxAllowedFilesCount, + uploadButtonLabel, allowedFileExtensions, allowedFileTypes, allowedFileTypesLabel,