Skip to content

fix(muya): ignore a quick-insert pick once its paragraph is gone (#5213) - #5289

Merged
Jocs merged 2 commits into
developfrom
fix/5213-quick-insert-stale-block
Sep 10, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5213-quick-insert-stale-block

Conversation

@Jocs

@Jocs Jocs commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #5213

Crash report (v0.20.0-rc.1): TypeError: Cannot destructure property 'path' of 'this.parent' as it is null. The stack runs from a click on a quick-insert item: ParagraphQuickInsertMenu.selectItem → replaceBlockByLabel → finishInsertedBlock → placeCaretInNewBlock → ParagraphContent.setCursor.

Cause: the menu stores the paragraph where / was typed and never re-checks it in selectItem. If that paragraph has left the document while the menu is still open:

  • replaceBlockByLabel calls block.replaceWith(newBlock), which only logs a warning for a block without a parent, so the new block is never inserted.
  • It then moves the caret into the orphaned new block, whose path cannot be resolved.

Fix: selectItem only replaces the block while it is still attached (outMostBlock), the same guard the code-block language selector got in #4677. The menu hides either way.

About the test: I could not find the user action that removes the paragraph while the menu stays open (undo with the menu open leaves it in place). The e2e test removes the paragraph directly, like the #4654 language-selector test.

Test plan

  • e2e, Chromium (e2e/tests/ui/quick-insert-detached-5213.spec.ts): open the menu with /, remove the paragraph, click "Bullet List". Expected: no pageerror, and the menu hides. Before the fix: the TypeError above.
  • e2e/tests/ui/slash-menu.spec.ts still passes
  • pnpm -C packages/muya test, pnpm -C packages/muya lint:types, eslint on the changed file

🤖 Generated with Claude Code

https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR

Jocs and others added 2 commits September 10, 2026 20:48
The quick-insert menu remembers the paragraph where `/` was typed. If that
paragraph left the document while the menu was still open, picking an
item passed it to `replaceBlockByLabel`. `replaceWith` bails for a block
without a parent, so the new block was never inserted, and moving the
caret into it threw "Cannot destructure property 'path' of 'this.parent'
as it is null".

Only replace the block while it is still attached; the menu hides either
way.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
@Jocs
Jocs merged commit eccdb43 into develop Sep 10, 2026
7 checks passed
@Jocs
Jocs deleted the fix/5213-quick-insert-stale-block branch September 10, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected error with message Cannot destructure property 'path' of 'this.parent' as it is null.

1 participant