Trac 48536 admin add ctrl cmd enter shortcut#11486
Trac 48536 admin add ctrl cmd enter shortcut#11486vidushigupta0607 wants to merge 2 commits intoWordPress:trunkfrom
Conversation
Allow submitting the comment reply/edit form in wp-admin with Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac), matching the existing frontend comment form behavior added in ticket #41545. The handler is added to the existing keydown event on the comment textarea, preventing listener stacking and respecting IME composition state. Implements Trac #48536.
8a463c5 to
08e05a1
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Add QUnit tests to verify the Ctrl+Enter / Cmd+Enter keyboard shortcut behavior on admin comment reply/edit forms. Tests cover: - Ctrl+Enter submission (Windows/Linux) - Cmd+Enter submission (Mac) - Plain Enter does not submit - IME composition state blocks submission - Shift/Alt modifiers prevent submission - Event type validation Fixes Trac #48536
08e05a1 to
79f97da
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Problem
The WordPress admin comment reply/edit forms did not support the Ctrl+Enter / Cmd+Enter keyboard shortcut for submitting comments. While this convenient shortcut was available for frontend comment forms (added in ticket #41545), wp-admin users had to reach for the mouse to click the Submit button, creating an inconsistent experience across frontend and backend.
Root Cause
The root cause was that the comment reply/edit form handler in edit-comments.js lacked the necessary keyboard vent logic to detect and handle the Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) key combination. While the file contained handlers for other keyboard interactions (Escape to cancel, Enter on text inputs), there was no support for the modifier+Enter pattern used to submit the textarea content.
Solution
Added keyboard event detection to the existing contextmenu keydown handler on the #replycontent textarea inside commentReply.open() in src/js/_enqueues/admin/edit-comments.js:
This addition:
Example Usage
After this change, users can submit admin comment replies and edits using the keyboard shortcut:
Impact
This enhancement improves the WordPress admin user experience by providing keyboard-savvy users with a faster workflow for managing comments. The implementation maintains consistency with the frontend comment form behavior while following WordPress JavaScript coding standards and accessibility best practices (IME-aware composition detection).
Trac Link
https://core.trac.wordpress.org/ticket/48536