Repository navigation
fix(muya): keep the image resize bar from crashing after its image is removed (#5216) - #5288
Merged
Merged
Conversation
…#5216) Clicking an image emits `muya-transformer` with the image container and defers `_render()` to a timer. Deleting the selected image right away (Delete, Backspace or Enter) emits `{ reference: null }` before that timer runs, so the render ran against a null reference and `_update` threw "Cannot read properties of null (reading 'getBoundingClientRect')". Only render when the reference is still the one that scheduled it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
Hiding the resize bar removed its handles but left the drag's mousemove and mouseup listeners attached. Deleting the image while holding a handle clears the reference, so the next mousemove threw "Cannot read properties of null (reading 'querySelector')" — the crash reported against the legacy image transformer in #4976, #4995 and #5057. Detach the drag listeners and reset the drag state whenever the bar hides, so a stale width cannot leak into a later resize either. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
…-drag (#5216) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR
This was referenced Sep 15, 2026
Unexpected error with message Cannot read properties of null (reading 'getBoundingClientRect')
#5352
Closed
Closed
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 #5216
Fixes #4976
Fixes #4995
Fixes #5057
The image resize bar (
ImageResizeBar) crashed when its image went away before it finished working with it. There were two separate races:1. Deferred render after the image is deleted (#5216, v0.20.0-rc.1)
muya-transformerwith the image container and schedules_render()withsetTimeout.{ reference: null }before the timer fires.TypeError: Cannot read properties of null (reading 'getBoundingClientRect')inImageResizeBar._update.2. Mouse move after the bar hides mid-drag (#4976, #4995, #5057)
HTMLBodyElement.mouseMove, nullgetBoundingClientRect/querySelector).@muyajs/corehas the same bug.hide()removed the handles but left the drag'smousemove/mouseuplisteners attached.Cannot read properties of null (reading 'querySelector').hide()detaches the drag listeners and resets the drag state (anchor, width, resizing flag), so a stale width also cannot leak into a later resize.Test plan
e2e/tests/drag/image-resize-bar-detached-5216.spec.ts):pageerror, no handles left. Before: thegetBoundingClientRectTypeError.pageerror. Before: thequerySelectorTypeError, four times.e2e/tests/drag/image-resize.spec.tsandimage-resize-bar-reflow-2939.spec.tsstill pass.src/ui/imageResizeBar/__tests__/imageResizeBar.spec.ts): both races, red before the fix.pnpm -C packages/muya test,pnpm -C packages/muya lint:types, eslint on the changed files🤖 Generated with Claude Code
https://claude.ai/code/session_015EPgRzXj7DDhJToWxHtkkR