Skip to content

fix(shortcut): skip editing shortcuts when the editor input is gone - #13861

Closed
yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/shortcut-without-editor
Closed

yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/shortcut-without-editor

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Editing shortcuts do nothing when the editor input is gone

Pressing Alt+U (Ctrl+U on macOS, delete to the start of the line) right as the block editor closed threw an uncaught

TypeError: Cannot read properties of null (reading 'value')
    at (shortcut fn) frontend.modules.shortcut.config
    at frontend.handler.plugin/hook-lifecycle-fn!
    at goog.ui.KeyboardShortcutHandler ...

Found by a local key fuzzer that records uncaught page errors. The same could happen with Alt+K (delete to the end of the line), Alt+D / Ctrl+W, Alt+W (delete word forward / backward) and the forward and backward word movement shortcuts.

Cause

These shortcuts run only while state/editing? is true, but that flag stays true for a moment after the textarea has left the DOM (the block was just deleted, the editor closed), so state/get-input returns nil. Their handlers (kill-line-before!, kill-line-after!, forward-kill-word, backward-kill-word, cursor-forward-word, cursor-backward-word) pass that nil to helpers that read (.-value input).

Change

src/main/frontend/modules/shortcut/config.cljs wraps these handlers in when-editing-input, which calls the handler only when state/get-input returns an element and otherwise does nothing.

Tests

src/test/frontend/modules/shortcut/config_test.cljs: calls each of these shortcut fns with state/get-input redefined to return nil and asserts none of them throws; the Alt+U one throws on master.

CI's unit suite and lint pass locally.


Devin Review

Pressing alt+u (ctrl+u on mac) right as the block editor closed threw an
uncaught "TypeError: Cannot read properties of null (reading 'value')".
The same could happen with alt+k, alt+d/ctrl+w, alt+w and the forward and
backward word shortcuts.

These shortcuts run only while state/editing? is true, but that flag stays
true for a moment after the textarea has left the DOM, so state/get-input
returns nil. Their handlers (kill-line-before!, kill-line-after!,
forward-kill-word, backward-kill-word, cursor-forward-word,
cursor-backward-word) pass that nil straight to helpers that read
(.-value input).

The shortcut config now wraps these handlers in when-editing-input, which
calls the handler only when state/get-input returns an element and
otherwise does nothing.

config-test calls each of these shortcut fns with state/get-input
redefined to return nil and asserts that none of them throws.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Superseded by #13865, which fixes the cause for the whole group instead of each shortcut: the block-editing shortcut gate now requires a live editor input as well as editing? (escape-editing exempt), so every shortcut of the group, including ones added later, does nothing once the textarea is gone. Closing to keep the fix for this class in one place.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/shortcut-without-editor branch November 17, 2026 02:20
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.

1 participant