Repository navigation
Conversation
Keydown shortcuts that preventDefault (word/line delete, select all, format, undo/redo, Ctrl+O, copy/cut of a non-range selection) also ran when a decorator's own input had the focus, so eg. Ctrl+Backspace or Cmd+A did nothing in it. Skip them when the keydown targets a captured decorator input, as beforeinput/input already do. Signed-off-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com> Co-authored-by: Ved Thakar <111605341+Vedthakar@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vedthakar
force-pushed
the
fix/3761-decorator-input-shortcuts
branch
from
October 21, 2026 21:37
2409623 to
0ce5803
Compare
Owner
Author
|
Superseded by meta#9428. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This solves issue meta#3761: some shortcuts do nothing in an input inside a decorator node, for example Ctrl+Delete / Ctrl+Backspace in the playground's poll inputs, or Cmd+A on macOS.
Current behavior. The editor's keydown listener on the root also gets keydowns from a decorator's own
<input>. Its shortcut table runs them as editor shortcuts. Theprevent(...)shortcuts and select all callevent.preventDefault()before dispatching their command:So the browser never deletes the word or selects the input's text, and the command acts on the editor's selection instead.
beforeinputandinputalready skip a decorator's captured input (meta#8740, viaisInputEventTargetingCapturedSelection), but keydown didn't.What this changes.
preventDefault()or dispatching when the keydown targets a decorator's captured input. This reuses the same helper, renamedisEventTargetingCapturedSelectionand widened toKeyboardEvent. It checks the composed target, then falls back to the deep active element, as forbeforeinput.preventDefault()s only for a non-range selection, gets the same check. That way Mod+C/X in the input isn't cancelled at keydown while a decorator is node-selected. This is compatible with open PR [lexical-plain-text][lexical-rich-text] Bug Fix: Leave a copy, cut or paste in a decorator's input to the input meta/lexical#9288, which handles the clipboard events themselves.<input>on the page.Closes meta#3761
Test plan
New browser test
packages/lexical/src/__tests__/browser/Issue3761DecoratorInputShortcuts.test.ts, with a block decorator holding an<input>:defaultPreventedand doesn't dispatch the command.defaultPrevented, and COPY/CUT_COMMAND isn't dispatched.defaultPreventedand dispatches its command once.hello worldbecomeshello, and the editor is unchanged.Before
On
mainwith the test applied and the source change reverted:After
Author: Ved Thakar (@Vedthakar)