Skip to content

test: re-enable the Cmd/Ctrl+Enter form submit hotkey spec - #4685

Merged
Paul-Bob merged 1 commit into
mainfrom
avo-1117/test/re-enable-hotkey-spec
Aug 4, 2026
Merged

test: re-enable the Cmd/Ctrl+Enter form submit hotkey spec#4685
Paul-Bob merged 1 commit into
mainfrom
avo-1117/test/re-enable-hotkey-spec

Conversation

@Mihai-Munteanu

Copy link
Copy Markdown
Contributor

Closes AVO-1117.

Why it was disabled

The "submits the form with command or control enter" example in spec/system/avo/group_1/hotkey_spec.rb was commented out during the Avo 4 open beta. It dispatched the keydown on document.body — but events bubble up, so it never reached the <form> element that actually carries the binding:

# lib/avo/concerns/form_builder.rb:14
action: "keydown.ctrl+enter->form#submit keydown.meta+enter->form#submit"

What it did exercise was the Save button's @github/hotkey "Mod+Enter" (app/components/avo/resource_component.rb:217). That one is document-level, but Mod resolves to Meta on macOS and Ctrl on Linux — so the test passed locally with meta_key: true and would have failed on CI.

Verified in the browser:

dispatched from Cmd+Enter Ctrl+Enter
document.body submits (via @github/hotkey, macOS only) nothing
focused field requestSubmit() requestSubmit()

The fix

Dispatch from the focused field so the test covers the real Stimulus binding, which is platform-independent, and run it for both modifiers.

  • dispatch_active_element_keydown gained ctrl_key:/meta_key: kwargs (defaulting to false), matching the sibling dispatch_keydown helper. Stimulus checks modifier flags exactly, so the unset one must be false.
  • Added a small focus_field helper — fill_in leaves document.activeElement on body under Cuprite.

Testing

  • 2 examples, 0 failures for the re-enabled examples
  • 38 examples, 0 failures for the full file, three consecutive runs

🤖 Generated with Claude Code

The example was commented out because it dispatched the keydown on
`document.body`. Events bubble up, so it never reached the `form` element
that carries the binding (`keydown.ctrl+enter->form#submit
keydown.meta+enter->form#submit`, lib/avo/concerns/form_builder.rb).

It only ever exercised the Save button's `@github/hotkey` "Mod+Enter",
which is document-level but resolves to Meta on macOS and Ctrl on Linux —
so it passed locally with `meta_key: true` and would have failed on CI.

Dispatch from the focused field instead, which tests the real Stimulus
binding and is platform-independent, and cover both modifiers. `fill_in`
leaves focus on `body` under Cuprite, hence the explicit `focus_field`.

Closes AVO-1117

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 31, 2026

Copy link
Copy Markdown

AVO-1117

@github-actions github-actions Bot added the test label Jul 31, 2026
@Paul-Bob
Paul-Bob merged commit cb49666 into main Aug 4, 2026
25 checks passed
@Paul-Bob
Paul-Bob deleted the avo-1117/test/re-enable-hotkey-spec branch August 4, 2026 08:54
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants