Repository navigation
fix(muya): drop an image selection whose block left the document (#5055) - #5291
Merged
Merged
Conversation
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
…is removed (#5055) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
Closed
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.
Summary
Fixes #5055
Crash report (0.20.0-dev build):
TypeError: Cannot destructure property 'path' of 'this.parent' as it is null.The stack runsset text←ParagraphContent.deleteImage←HTMLDocument._handleKeydown(inImageSelection).Cause:
ImageSelectionremembers 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,deleteImagewrotetexton 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/tests/editing/image-selection-detached-5055.spec.ts): click an image, remove its paragraph, press Backspace. Expect nopageerror. Before the fix: the TypeError above.e2e/tests/drag/image-resize.spec.tsstill passespnpm -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