From 7c01bbb6d05cacf94789f2c6817e3b269a3542b8 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sun, 22 Nov 2026 21:41:32 +0100 Subject: [PATCH 1/5] fix(linearscale): clear the required error once a value is picked A required linear scale left empty shows "You must answer this question" and marks its radio buttons invalid. Picking a value did not clear either until the next submit attempt, so screen readers went on announcing the picked value as invalid. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/required-fields.spec.ts | 26 +++++++++++++++++++ .../Questions/QuestionLinearScale.vue | 1 + 2 files changed, 27 insertions(+) diff --git a/playwright/e2e/required-fields.spec.ts b/playwright/e2e/required-fields.spec.ts index 27743973d..8caa4c9f1 100644 --- a/playwright/e2e/required-fields.spec.ts +++ b/playwright/e2e/required-fields.spec.ts @@ -9,6 +9,7 @@ import { test as appNavigationTest } from '../support/fixtures/navigation.ts' import { test as randomUserTest } from '../support/fixtures/random-user.ts' import { test as submitTest } from '../support/fixtures/submit.ts' import { test as topBarTest } from '../support/fixtures/topBar.ts' +import { api } from '../support/helpers.ts' import { QuestionType } from '../support/sections/QuestionType.ts' import { FormsView } from '../support/sections/TopBarSection.ts' @@ -83,3 +84,28 @@ test.describe('Required field validation', () => { await expect(submitView.successMessage).toBeVisible() }) }) + +test('A required linear scale clears its error once a value is picked', async ({ + page, + submitView, +}) => { + const form = await api(page.request, 'POST', '/forms') + const scale = await api(page.request, 'POST', `/forms/${form.id}/questions`, { + type: 'linearscale', + text: 'Rate the event', + }) + await api(page.request, 'PATCH', `/forms/${form.id}/questions/${scale.id}`, { + keyValuePairs: { isRequired: true }, + }) + await page.goto(`apps/forms/${form.hash}/submit`) + + await submitView.submitButton.click() + const question = submitView.getQuestion('Rate the event') + await expect(question.getByText('You must answer this question')).toBeVisible() + + await submitView.checkRadio('Rate the event', '3') + await expect(question.getByText('You must answer this question')).toBeHidden() + await expect(question.getByRole('radio').first()).not.toHaveAttribute( + 'aria-invalid', + ) +}) diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index c08e67413..660183484 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -289,6 +289,7 @@ export default defineComponent({ const onChange = (option: string): void => { emit('update:values', [option]) + question.errorMessage.value = null } const onOptionsLowestChange = (value: number): void => { From 8cb2e70a45612645292eb7979cb1816438837e61 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sun, 22 Nov 2026 21:41:45 +0100 Subject: [PATCH 2/5] fix(a11y): reference only rendered elements from a linear scale In the editor the radio buttons of a linear scale referenced the question title as their group name and the label of the lowest value as the description of the first one, but both are only rendered on the submit page, so the references pointed nowhere. On the submit page the description of the first radio button pointed nowhere as well when the label of the lowest value is empty. Both are now set only where the element exists. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/a11y-question-inputs.spec.ts | 6 ++++++ src/components/Questions/QuestionLinearScale.vue | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index c32bc14f1..98848b964 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -212,6 +212,12 @@ test.describe('Accessibility: aria attributes on question inputs', () => { exact: true, }), ).toBeVisible() + await expect( + questions[0].section.locator('fieldset.question-linear-scale__options'), + ).not.toHaveAttribute('aria-labelledby') + await expect( + questions[0].section.getByRole('radio').first(), + ).not.toHaveAttribute('aria-describedby') await topBar.toggleView(FormsView.View) diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index 660183484..e6dc25c3b 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -73,8 +73,10 @@
+ :aria-labelledby="readOnly ? titleId : undefined" + :aria-describedby=" + readOnly && description ? descriptionId : undefined + "> {{ t('forms', 'From {firstOption} to {lastOption}', { @@ -90,7 +92,11 @@ Date: Sun, 22 Nov 2026 21:02:50 +0100 Subject: [PATCH 3/5] fix(a11y): describe the last option of a linear scale by its label The first option of a linear scale is described by the label of the lowest value, but nothing referenced the label of the highest value: the hidden legend that names both is overridden by the question title. Screen reader users moving through the options heard what the lowest value means, but never what the highest one means, which on a 0 to 10 scale is what tells them the direction. The last option is now described by the label of the highest value where it is shown. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/a11y-question-inputs.spec.ts | 3 ++ .../Questions/QuestionLinearScale.vue | 37 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index 98848b964..8979a617d 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -226,6 +226,9 @@ test.describe('Accessibility: aria attributes on question inputs', () => { await expect(fieldset).toHaveAttribute('aria-labelledby', 'q1_title') await expect(fieldset).toHaveAttribute('aria-describedby', 'q1_desc') + const radios = fieldset.getByRole('radio') + await expect(radios.first()).toHaveAccessibleDescription('Strongly disagree') + await expect(radios.last()).toHaveAccessibleDescription('Strongly agree') await expect( page.getByRole('heading', { name: 'Rate your experience' }), diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index e6dc25c3b..79720e7c0 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -92,11 +92,7 @@
{{ optionsLabelHighest }}
@@ -250,6 +247,34 @@ export default defineComponent({ * ID for the label for the lowest option */ const labelId = computed(() => 'q' + props.index + '__label_lowest') + + /** + * ID for the label for the highest option + */ + const labelHighestId = computed(() => 'q' + props.index + '__label_highest') + + /** + * ID of the shown label that describes an option: the lowest label for the first option, + * the highest label for the last one + * + * @param index the position of the option + */ + const optionLabelId = (index: number): string | undefined => { + if (!props.readOnly) { + return undefined + } + if (index === 0 && optionsLabelLowest.value !== '') { + return labelId.value + } + if ( + index === scaleOptions.value.length - 1 + && optionsLabelHighest.value !== '' + ) { + return labelHighestId.value + } + return undefined + } + const isUnique = computed(() => props.answerType.unique === true) /** @@ -345,6 +370,8 @@ export default defineComponent({ isUnique, questionValues, labelId, + labelHighestId, + optionLabelId, optionsLowest, optionsHighest, optionsLabelLowest, From e1cf4ababf9367b0472d74e8b893d94ec68c5f8b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sun, 22 Nov 2026 21:02:51 +0100 Subject: [PATCH 4/5] fix(a11y): show the labels of a linear scale legend as written The hidden legend of a linear scale names its lowest and highest label. The translation function escaped them for HTML, but the legend is plain text, so a label with an apostrophe or an ampersand reached screen readers as "Don't agree" or "&". The legend now takes the labels as written, like the other texts that hold user input. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/a11y-question-inputs.spec.ts | 13 ++++++++++++- src/components/Questions/QuestionLinearScale.vue | 13 +++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index 8979a617d..ea3f4ed17 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -8,6 +8,7 @@ import { test as formTest } from '../support/fixtures/form.ts' import { test as appNavigationTest } from '../support/fixtures/navigation.ts' import { test as randomUserTest } from '../support/fixtures/random-user.ts' import { test as topBarTest } from '../support/fixtures/topBar.ts' +import { waitForApiResponse } from '../support/helpers.ts' import { GridSubtype, QuestionType } from '../support/sections/QuestionType.ts' import { FormsView } from '../support/sections/TopBarSection.ts' @@ -212,6 +213,11 @@ test.describe('Accessibility: aria attributes on question inputs', () => { exact: true, }), ).toBeVisible() + const savedLabel = waitForApiResponse(page, 'PATCH') + await questions[0].section + .getByRole('textbox', { name: 'Label for lowest value', exact: true }) + .fill("Don't agree & leave") + await savedLabel await expect( questions[0].section.locator('fieldset.question-linear-scale__options'), ).not.toHaveAttribute('aria-labelledby') @@ -226,8 +232,13 @@ test.describe('Accessibility: aria attributes on question inputs', () => { await expect(fieldset).toHaveAttribute('aria-labelledby', 'q1_title') await expect(fieldset).toHaveAttribute('aria-describedby', 'q1_desc') + await expect(fieldset.locator('legend')).toHaveText( + "From Don't agree & leave to Strongly agree", + ) const radios = fieldset.getByRole('radio') - await expect(radios.first()).toHaveAccessibleDescription('Strongly disagree') + await expect(radios.first()).toHaveAccessibleDescription( + "Don't agree & leave", + ) await expect(radios.last()).toHaveAccessibleDescription('Strongly agree') await expect( diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index 79720e7c0..c53114a47 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -79,10 +79,15 @@ "> {{ - t('forms', 'From {firstOption} to {lastOption}', { - firstOption: optionsLabelLowest, - lastOption: optionsLabelHighest, - }) + t( + 'forms', + 'From {firstOption} to {lastOption}', + { + firstOption: optionsLabelLowest, + lastOption: optionsLabelHighest, + }, + { escape: false, sanitize: false }, + ) }}
Date: Sun, 22 Nov 2026 21:02:52 +0100 Subject: [PATCH 5/5] fix(a11y): name the options of a linear scale directly The radio buttons of a linear scale have no label text of their own, so the component gave them an aria-labelledby pointing to a label that is never rendered. Browsers fell back to the number next to each button, but the reference itself was broken. The options are now named by their value directly. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/a11y-question-inputs.spec.ts | 2 ++ src/components/Questions/QuestionLinearScale.vue | 1 + 2 files changed, 3 insertions(+) diff --git a/playwright/e2e/a11y-question-inputs.spec.ts b/playwright/e2e/a11y-question-inputs.spec.ts index ea3f4ed17..18722d3b2 100644 --- a/playwright/e2e/a11y-question-inputs.spec.ts +++ b/playwright/e2e/a11y-question-inputs.spec.ts @@ -236,6 +236,8 @@ test.describe('Accessibility: aria attributes on question inputs', () => { "From Don't agree & leave to Strongly agree", ) const radios = fieldset.getByRole('radio') + await expect(radios.first()).toHaveAccessibleName('1') + await expect(radios.first()).not.toHaveAttribute('aria-labelledby') await expect(radios.first()).toHaveAccessibleDescription( "Don't agree & leave", ) diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue index c53114a47..fae0b360c 100644 --- a/src/components/Questions/QuestionLinearScale.vue +++ b/src/components/Questions/QuestionLinearScale.vue @@ -97,6 +97,7 @@