From a04ec2cdff3a8d21538bc9897cab41391995c45f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 19 Nov 2026 15:44:18 +0100 Subject: [PATCH] fix(submit): show the first unanswered required question on submit The questions handle the invalid event themselves to show their own error message, which also stops the browser from focusing the first invalid input and scrolling to it. With a required question out of view, Submit did nothing visible: no request, no focus, and the error message off-screen. The form now focuses the input of the first invalid question of a submit attempt and scrolls that question into view. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- playwright/e2e/required-fields.spec.ts | 15 +++++++++++++ src/views/Submit.vue | 30 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/playwright/e2e/required-fields.spec.ts b/playwright/e2e/required-fields.spec.ts index d514694f39..27743973d1 100644 --- a/playwright/e2e/required-fields.spec.ts +++ b/playwright/e2e/required-fields.spec.ts @@ -57,6 +57,21 @@ test.describe('Required field validation', () => { await expect(submitView.successMessage).not.toBeVisible() }) + test('Submit brings an empty required field out of view into focus', async ({ + page, + topBar, + submitView, + }) => { + await page.setViewportSize({ width: 420, height: 400 }) + await topBar.toggleView(FormsView.View) + + await submitView.submitButton.click() + + const input = submitView.getQuestion('Required field').getByRole('textbox') + await expect(input).toBeFocused() + await expect(input).toBeInViewport() + }) + test('Submit succeeds after filling required field', async ({ topBar, submitView, diff --git a/src/views/Submit.vue b/src/views/Submit.vue index ca92147481..ca08a9a1f6 100644 --- a/src/views/Submit.vue +++ b/src/views/Submit.vue @@ -133,7 +133,11 @@ -
+
    { + invalidShown = false + }) + + const input = event.target as HTMLElement + input.focus({ preventScroll: true }) + input.closest('.question')?.scrollIntoView({ block: 'center' }) + } + /** * Ctrl+Enter typically fires submit on forms. * Some inputs do automatically, while some need explicit handling @@ -1255,6 +1282,7 @@ export default defineComponent({ isExpired, isMaxSubmissionsReached, loading, + onInvalid, onKeydownCtrlEnter, onKeydownEnter, onSubmit,