Repository navigation
fix(editor): editing shortcuts need a live editor input - #13865
Open
yuxi-liu-wired wants to merge 1 commit into
Open
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
This was referenced Oct 27, 2026
yuxi-liu-wired
force-pushed
the
fix/editing-shortcuts-need-an-input
branch
3 times, most recently
from
November 3, 2026 12:01
9d406e7 to
04f9266
Compare
yuxi-liu-wired
force-pushed
the
fix/editing-shortcuts-need-an-input
branch
7 times, most recently
from
November 18, 2026 14:38
c0f3a3a to
85337ba
Compare
`state/editing?` can stay true for a moment after the editor's textarea has left the DOM (the block was just deleted, the editor closed), so `state/get-input` returns nil while the shortcut handler still treats the user as editing. The block-editing shortcuts were gated on `editing?` alone and then read the missing textarea, throwing uncaught TypeErrors; a local key fuzzer hit Alt+E (end of block, setSelectionRange of null) and Alt+U (delete to line start, reading 'value' of null), and the same holds for Alt+A, Alt+K, the word movement and word delete shortcuts and the rest of the group. enable-when-editing-mode!, the gate of the block-editing shortcut group, now also requires a live input. escape-editing is exempt (:allow-without-input? in its config), since it is what clears such a leftover editing state. Up/Down at the edge of a code block calls util/get-prev-block-non-collapsed from CodeMirror's own key handler, outside the shortcut gate; with the block element gone it passed nil to skip-same-top-blocks (getAttribute of null). It now returns nil for a nil block, as get-next-block-non-collapsed already did. Tests: before_test runs the gate with a leftover editing state, with escape's exemption, with a live input and while not editing, and every shortcut of the block-editing group with editing? true and no input (14 failures without the change); util-block-nav-test asks for the previous and next block of nil.
yuxi-liu-wired
force-pushed
the
fix/editing-shortcuts-need-an-input
branch
from
November 19, 2026 12:01
85337ba to
71e5f47
Compare
This branch has not been deployed
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.
Editing shortcuts need a live editor input
state/editing?can stay true for a moment after the editor's textarea has left the DOM (the block was just deleted, the editor closed). In that windowstate/get-inputreturns nil while the shortcut handler still treats the user as editing, and every block-editing shortcut that reads the textarea throws an uncaught TypeError. A local key fuzzer that records uncaught page errors hit:and the same holds for Alt+A, Alt+K, the word movement and word delete shortcuts and the rest of the block-editing group.
Change
frontend.modules.shortcut.before/enable-when-editing-mode!, the gate of the:shortcut.handler/block-editing-onlygroup, now requires a live input as well asediting?. This covers the whole group, including shortcuts added to it later, instead of a nil check in each handler.:editor/escape-editingis exempt (:allow-without-input? truein its config), since it is what clears a leftover editing state.util/get-prev-block-non-collapsedfrom CodeMirror's own key handler, outside the shortcut gate. With the block element gone it passed nil toskip-same-top-blocks; it now returns nil for a nil block, asget-next-block-non-collapsedalready does.Tests
src/test/frontend/modules/shortcut/before_test.cljs: the gate with a leftover editing state (does not run), with escape's exemption, with a live input, and while not editing; and every shortcut of the block-editing group, installed the way the shortcut handler installs them, pressed withediting?true and no input: none throws (14 failures on master).src/test/frontend/util_block_nav_test.cljs: the previous and next block of nil are nil (throws on master).CI's unit suite and lint pass locally.
This replaces #13856 (a nil check in
cursor/move-cursor-to) and #13861 (nil checks in six shortcut fns): the gate covers both, and every other shortcut of the group.