fix: #5394 cancel image resize when the document rebuilds by Jocs · Pull Request #5721 · marktext/marktext · GitHub
Skip to content

fix: #5394 cancel image resize when the document rebuilds - #5721

Merged
Jocs merged 1 commit into
developfrom
fix/5394-image-resize-reload
Oct 12, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/5394-image-resize-reload

Conversation

@Jocs

@Jocs Jocs commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #5394

Summary

Reloading a file from disk, or undoing across a reload, while an image resize handle is held rebuilds the document tree. The resize bar retains the detached image block and tries to write its width on mouseup, throwing Cannot destructure property 'path' of 'this.parent' as it is null.

Cancel the resize before replacing the block tree, clear the cached image references and mouse listeners when hiding the bar, and guard deferred rendering, positioning, movement and release against a detached image. Releasing after reload or undo now quietly cancels the resize; the new document is preserved and a subsequent resize still works.

The current develop branch also reloads clean documents with Auto Save off, so regression coverage includes both Auto Save settings as well as the Edit > Undo action.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added: detached-reference unit tests and real Electron drag/reload/undo regression tests using actual disk writes and the file watcher.
  • Manually tested on: automated Electron validation on macOS; no separate manual test run.

Validation passed:

  • pnpm -C packages/muya test — 2470 tests passed.
  • pnpm -C packages/desktop exec playwright test test/e2e/issue-5394-image-resize-reload.spec.ts test/e2e/external-reload-undo.spec.ts test/e2e/issue-3652-auto-reload.spec.ts — 7 tests passed.
  • pnpm run build:unpack
  • pnpm run typecheck
  • pnpm -C packages/muya lint:types
  • pnpm run lint — no errors; existing repository warnings.
  • Muya ESLint checks for the changed source and unit tests.

Notes for reviewers

Real Electron tests assert that an external reload or undo cancels the held resize, preserves the updated document, reports no renderer error, saves no stale width, and allows a fresh drag to commit a width.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@Jocs
Jocs force-pushed the fix/5394-image-resize-reload branch from d956f51 to 42b7e2a Compare October 12, 2026 13:48
@github-actions

Copy link
Copy Markdown
Contributor

@Jocs
Jocs merged commit 95c6d09 into develop Oct 12, 2026
18 of 19 checks passed
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.

[Bug] "Cannot destructure property 'path' of 'this.parent'" error when the document reloads or is undone while an image resize handle is held

1 participant