Repository navigation
fix(submit): only submit the form by button or Ctrl/Cmd+Enter - #3951
AndyScherzinger wants to merge 1 commit into
Conversation
|
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>
71c206a to
7cd1df3
Compare
|
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 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 |
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:
aria-keyshortcuts="Control+Enter Meta+Enter".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:
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.tscovers Shift+Enter, Ctrl+Enter and Cmd+Enter.🤖 AI (if applicable)