Skip to content

fix(muya): drop an image selection whose block left the document (#5055) - #5291

Merged
Jocs merged 2 commits into
developfrom
fix/5055-image-selection-stale-block
Sep 10, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5055-image-selection-stale-block

Conversation

@Jocs

@Jocs Jocs commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #5055

Crash report (0.20.0-dev build): TypeError: Cannot destructure property 'path' of 'this.parent' as it is null. The stack runs set text ← ParagraphContent.deleteImage ← HTMLDocument._handleKeydown (in ImageSelection).

Cause: ImageSelection remembers the clicked image, including its block, until the next click. Its document-level keydown handler deletes that image on Backspace, Delete or Enter. If the block was removed or replaced in the meantime, deleteImage wrote text on a detached block, and that block's OT path cannot be resolved.

Fix: the keydown handler now drops a selection whose block is no longer in the document (outMostBlock) and lets the key through.

Test limitation: as with #5213, I couldn't find the user action that replaces the paragraph while the image stays selected, so the e2e test removes the paragraph directly.

Test plan

  • e2e, Chromium (e2e/tests/editing/image-selection-detached-5055.spec.ts): click an image, remove its paragraph, press Backspace. Expect no pageerror. Before the fix: the TypeError above.
  • e2e/tests/drag/image-resize.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 21:18
Clicking an image remembers its block in the image selection until the
next click. If that block left the document in the meantime, pressing
Backspace, Delete or Enter called `deleteImage` on it, and its text
setter threw "Cannot destructure property 'path' of 'this.parent' as it
is null".

Forget such a selection and let the key through instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
@Jocs
Jocs merged commit 7745f7d into develop Sep 10, 2026
7 checks passed
@Jocs
Jocs deleted the fix/5055-image-selection-stale-block branch September 10, 2026 14:05
@Jocs Jocs mentioned this pull request Sep 18, 2026
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