Skip to content

fix: Enter no longer submits when the submit button is hidden, and goes to the next step in multi-part forms (6.4.x) - #266

Closed
RensTillmann wants to merge 2 commits into
release/6.4.xfrom
fix/64-enter-hidden-submit
Closed

RensTillmann wants to merge 2 commits into
release/6.4.xfrom
fix/64-enter-hidden-submit

Conversation

@RensTillmann

@RensTillmann RensTillmann commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Pressing Enter in a field submitted the form even when the submit button was hidden by conditional logic (for example inside a Column whose conditions hide it). The Enter handler in elements.js took the first submit button with querySelector and never checked visibility; the server accepted the submission.

Now the handler uses the first submit button that is not inside a conditionally hidden parent (SUPER.has_hidden_parent); if none is visible, Enter does nothing. Multi-part behaviour, the disable-enter setting and buttons in invisible columns are unchanged.

LTS counterpart: separate PR.

Base branch

release/6.4.x: bug fix.

Tests

new tests/test-enter-key-client.cjs (real Enter handler + has_hidden_parent in node:vm): 6 cases; without the fix (b) and (c) fail; with the fix 6/6 (incl. invisible-column and loading-state guards)
all client tests: 44 pass
real browser (WordPress 7.1.1, PHP 8.2), released vs fix build:
  hidden submit button + Enter: released submits (+1 entry); fix: no request, 0 entries
  button visible again + Enter: +1 entry; visible button Enter and click: +1 each
  first button hidden, second visible: fix submits via the visible one
  2-step form and (6.4) invisible column: same as released; no console errors

Found during QA, not changed here: Enter in a filled step-1 field of a multi-part form submits the whole form from step 1 (same on released builds).

Merge

Draft: for QA and the next release session.

Update: Enter in multi-part forms

Second commit (approved behaviour change): in a multi-part form, Enter on a step that is not the last now clicks that step's own Next button (SUPER.switchMultipart with the step's validation) instead of submitting the whole form from step 1. On the last step Enter submits as before (first visible submit button). If the active step's Next button is hidden, or the step has no Next button, Enter does nothing (it never skips steps). Tests: tests/test-enter-key-client.cjs, 4 new multi-part cases fail on the previous code and pass now; all client tests pass.

@RensTillmann RensTillmann changed the title fix: Enter no longer submits a form whose submit button is hidden by conditional logic (6.4.x) fix: Enter no longer submits when the submit button is hidden, and goes to the next step in multi-part forms (6.4.x) Oct 20, 2026
@RensTillmann

Copy link
Copy Markdown
Owner Author

The fix is already released in 6.4.010 (release PR #299, merged 21 Oct 2026): src/assets/js/frontend/elements.js (Enter handler, around lines 1651-1677) makes Enter follow the step's visible Next button on non-final steps and only submit through a visible, non-read-only submit button. This PR's test file tests/test-enter-key-client.cjs was not part of that release and stays on this branch. The browser suite covers this on 6.4.010 (enter-key.spec.ts, 4 tests passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant