Skip to content

fix(dashboard): let Enter activate buttons inside modal and drawer forms - #17438

Merged
kodiakhq[bot] merged 1 commit into
developfrom
fix/keybound-form-enter-on-buttons
Oct 23, 2026
Merged

kodiakhq[bot] merged 1 commit into
developfrom
fix/keybound-form-enter-on-buttons

Conversation

@medusa-os-bot

@medusa-os-bot medusa-os-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

What — Pressing Enter on a focused button or link inside a KeyboundForm now activates it, the same as a click.

Why — Most admin forms in RouteFocusModal and RouteDrawer are wrapped in KeyboundForm. Its onKeyDown handler called event.preventDefault() on every Enter keydown unless the target was a textarea. Blocking implicit submission from inputs is intended. But the handler also cancelled the browser's native Enter activation on buttons and links. So keyboard users couldn't use Enter on the focus modal's header close button (e.g. the Create Customer modal), or on the drawer footer Cancel and Save buttons.

How — packages/admin/dashboard/src/components/utilities/keybound-form/keybound-form.tsx now returns early for HTMLButtonElement and HTMLAnchorElement targets, as it already did for textareas, unless Cmd/Ctrl is held. Enter in inputs still doesn't submit, and Cmd/Ctrl+Enter still submits from anywhere in the form.

Testing — Added src/components/utilities/keybound-form/__tests__/keybound-form.spec.ts. Before the fix, the button and link cases fail: preventDefault was called once when it shouldn't have been. After the fix they pass. The spec also covers the existing input and Cmd/Ctrl+Enter behavior. I also ran the full dashboard Vitest suite.


Checklist

  • I have added a changeset for this PR
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

  • The local environment runs Node 18, where jsdom fails to load. So the regression spec uses Vitest's default node environment with stubbed DOM element classes instead of rendering with Testing Library. I didn't check the change in a browser.
  • In the full dashboard suite, src/lib/__tests__/reload-on-preload-error.spec.ts times out locally. That spec doesn't touch KeyboundForm, and the timeouts look environmental.

Fixes #17172

Opened automatically by the Fix Bug workflow. Review carefully before merging.

@medusa-os-bot
medusa-os-bot Bot requested a review from a team as a code owner October 22, 2026 16:17
@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

ðŸĶ‹ Changeset detected

Latest commit: 266e662

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 83 packages
Name Type
@medusajs/dashboard Patch
@medusajs/draft-order Patch
@medusajs/loyalty-plugin Patch
@medusajs/admin-bundler Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/search Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/search-postgres Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/auth-oidc Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/instantsearch-adapter Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
create-medusa-app Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@medusa-os-bot

medusa-os-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution! Initial automated review looks good.

Verdict: Looks good for a final review by the team.

Extends KeyboundForm's Enter-key guard to let browser-native Enter activation pass through for focused buttons and anchors, restoring keyboard usability for close, cancel, and save controls inside modals and drawers.

Checked: security, performance, correctness, conventions, changeset, tests.

Suggestions (non-blocking):

  • A test case for the pre-existing textarea early-return path would guard against future regressions there (the textarea case is preserved by the fix but has no coverage in the new spec).

Triggered by: new PR opened

@kodiakhq
kodiakhq Bot merged commit 33decee into develop Oct 23, 2026
59 of 63 checks passed
@kodiakhq
kodiakhq Bot deleted the fix/keybound-form-enter-on-buttons branch October 23, 2026 06:54
@github-actions github-actions Bot mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pressing Enter key does not work in Modal close key and RouteDrawer.Footer

1 participant