[6.x] Fix Link fieldtype preventing Cmd+S keyboard shortcut in Entry mode - #14986
Conversation
|
Hey @jasonvarga, please check this when you have time. |
|
Sorry, we can't provide an ETA for reviewing/merging this pull request. 😞 It's already on our to-do list and we'll review it when we can. If you need to use this fix in the meantime, consider applying this PR as a composer patch. |
jasonvarga
left a comment
There was a problem hiding this comment.
🤖 This review was generated via an AI review.
Requires changes
- Critical: The new
forwardKeyboardShortcutshandler redispatches Cmd+S/Cmd+Enter todocument, but the original event already bubbles there naturally (reka-ui'sFocusScopedoesn't stop propagation for non-Tab keys). This double-fires the global save handler — verified empirically — causing a duplicate save request whenever Cmd+S is pressed with any Stack open, not just Link fields. - Warning: The
mod+returnbranch checksevent.key === 'return'/'Return', but the real value is'Enter', so that branch is dead code. - Note: The new tests only check that the internal
dispatchEventspy fired, so they wouldn't catch either issue above.
Would want FocusScope confirmed as the actual blocker (in a real browser) before this workaround goes in, and stopPropagation() on the original event if forwarding stays.
|
You were right that FocusScope isn't the blocker. I dropped the Stack workaround and pushed the actual fix. Propagation. In reka-ui 2.9.5, Double fire. Half right. It did double up plain
Tests. Correct. A spy on What actually breaks it. The fix is small: bind the shortcut only when the tree is editable, and destroy the binding on unmount. I verified it in a browser against the steps in #14598. Before, Cmd+S after choosing an entry sent no request at all. After, it sends one PATCH and no duplicates. The full JS suite passes. |
PageTreebindsmod+sglobally increated()and never destroys the binding. Mousetrap keeps one callback per combo, so a second bind removes the first.For structured collections, the Link fieldtype's Entry selector renders
PageTreewitheditable: false, andsave()returns immediately in that state. Opening the selector replaces the entry publish form's save shortcut with a no-op, and nothing restores it. Cmd+S stays dead for the rest of the page.This binds the shortcut only when the tree is editable, and destroys the binding on unmount.
Fixes #14598