From 35231177f31bdcceca6c414149e4f879757b3dad Mon Sep 17 00:00:00 2001 From: v01dst Date: Mon, 16 Nov 2026 14:56:34 +0200 Subject: [PATCH 1/2] 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, From 8a81d2bf1dda6cf6ef03c12ea7c31725a50a559e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 18 Nov 2026 15:41:51 +0100 Subject: [PATCH 2/2] fix(a11y): use the plural function for the upload button name 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 --- src/components/Questions/QuestionFile.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Questions/QuestionFile.vue b/src/components/Questions/QuestionFile.vue index 847eb40b9..56a4a8143 100644 --- a/src/components/Questions/QuestionFile.vue +++ b/src/components/Questions/QuestionFile.vue @@ -168,7 +168,7 @@ import axios from '@nextcloud/axios' import { showError } from '@nextcloud/dialogs' import { formatFileSize } from '@nextcloud/files' import { loadState } from '@nextcloud/initial-state' -import { t } from '@nextcloud/l10n' +import { n, t } from '@nextcloud/l10n' import { generateOcsUrl } from '@nextcloud/router' import { computed, defineComponent, onMounted, ref } from 'vue' import NcActionButton from '@nextcloud/vue/components/NcActionButton' @@ -270,9 +270,12 @@ export default defineComponent({ }) const uploadButtonLabel = computed(() => { - return maxAllowedFilesCount.value > 1 - ? t('forms', 'Upload files') - : t('forms', 'Upload a file') + return n( + 'forms', + 'Upload a file', + 'Upload files', + maxAllowedFilesCount.value, + ) }) const allowedFileExtensions = computed(() => {