Skip to content

fix(submit): only submit the form by button or Ctrl/Cmd+Enter - #3951

Open
AndyScherzinger wants to merge 1 commit into
mainfrom
fix/submit-ctrl-enter
Open

AndyScherzinger wants to merge 1 commit into
mainfrom
fix/submit-ctrl-enter

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #1048

Shift+Enter in a short answer submitted the form by accident (#1048): the questions only caught a plain Enter, so Enter with any modifier fell through to the browser's implicit form submission. Chromium and Firefox apply that to radio buttons, checkboxes and inputs without a handler of their own (the "Other" answer, grid cells) as well. At the same time Ctrl+Enter, the deliberate shortcut, only worked in a long text answer.

The form now handles Enter once for all its inputs, so it is only submitted by the submit button or a deliberate Ctrl+Enter / Cmd+Enter:

  • Ctrl+Enter or Cmd+Enter submits from any input or text area, once.
  • Enter, Shift+Enter or Alt+Enter in a single-line input, radio button or checkbox never submits; it moves on to the next field, now also into choice questions, where focus used to stay put.
  • Text areas keep Enter for a new line, file inputs still open the file picker on Enter, and Enter on the submit button still submits.
  • The submit button announces the shortcut with aria-keyshortcuts="Control+Enter Meta+Enter".
  • The per-question Enter handlers became dead and are removed.

Found in the review of #3637, which reworks the Enter handling of the submit view and fixes the same in its own code.

How to verify

On a form with a short answer, a radio question, a checkbox question with "Other", a long text and a file question:

  1. Press Enter and Shift+Enter in the short answer, on a radio button, on a checkbox and in the "Other" text: nothing is submitted, focus moves on to the next field.
  2. Press Enter and Shift+Enter in the long text: new lines are inserted.
  3. Press Enter on the file input: the file picker opens.
  4. Press Ctrl+Enter (Cmd+Enter on macOS) in the short answer or on an option: the form is submitted, once.
  5. Tab to the submit button and press Enter: the form is submitted.

Checked in Chromium and Firefox on NC 35 in the logged-in app, a public share link and the embedded form; no submission before the deliberate one in each. Playwright test in submit-form.spec.ts covers Shift+Enter, Ctrl+Enter and Cmd+Enter.

🤖 AI (if applicable)

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

@AndyScherzinger AndyScherzinger added the bug Something isn't working label Nov 21, 2026
@AndyScherzinger AndyScherzinger added the 3. to review Waiting for reviews label Nov 21, 2026
@AndyScherzinger AndyScherzinger added this to the 5.5 milestone Nov 21, 2026
@Chartman123

Copy link
Copy Markdown
Collaborator

Please cross check with #1048

Shift+Enter in a short answer submitted the form by accident (#1048).
The questions only caught a plain Enter, so Enter with any modifier
fell through to the browser's implicit form submission, which Chromium
and Firefox also apply to radio buttons, checkboxes and inputs without
their own handler, such as the "Other" answer and grid cells.
Ctrl+Enter, the deliberate shortcut, worked only in a long text answer.

The form now handles Enter once for all its inputs. Ctrl+Enter or
Cmd+Enter submits from any input or text area. Enter with any other
modifier in a single-line input moves on to the next field instead of
submitting, also past the field set of a choice question, where focus
used to stay put. Text areas keep their new line, file inputs open the
file picker, buttons keep their default. The submit button announces
the shortcut with aria-keyshortcuts. The per-question Enter handlers
became dead and are removed.

Fixes #1048

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger changed the title fix(submit): submit the form with Ctrl+Enter from every input fix(submit): only submit the form by button or Ctrl/Cmd+Enter Nov 21, 2026
@AndyScherzinger

Copy link
Copy Markdown
Member Author

Thanks, cross-checked. The accidental submit in #1048 came from Shift+Enter in a short answer: the question only caught a plain Enter, so Shift+Enter fell through to the browser's implicit form submission (Chromium and Firefox do the same for radio buttons and checkboxes). This PR now removes that: Enter and Shift+Enter in a single-line input, radio or checkbox never submit and move on to the next field. The form is only submitted by the submit button or the deliberate Ctrl+Enter / Cmd+Enter shortcut, which the button announces via aria-keyshortcuts. I added "Fixes #1048" to the description.

Whether a confirmation step on top is wanted is a separate question. @jancborchardt, from a design and accessibility point of view, should Forms ask for confirmation before submitting: always, only when the form is submitted with the keyboard shortcut, or as an opt-in per form (see #482)? I left it out of this PR, as it would add a step for every respondent.

Assisted by ClaudeCode:claude-opus-5-5

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 AI assisted bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask for confirmation before submitting form

3 participants