fix(muya): ignore a table tool click once its table left the document (#5442) by Jocs · Pull Request #5443 · marktext/marktext · GitHub
Skip to content

fix(muya): ignore a table tool click once its table left the document (#5442) - #5443

Merged
Jocs merged 2 commits into
developfrom
fix/table-tools-detached-5442
Sep 18, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/table-tools-detached-5442

Conversation

@Jocs

@Jocs Jocs commented Sep 18, 2026

Copy link
Copy Markdown
Member

Fixes #5442.

The table row menu and the table column toolbar remember the cell they were opened on. An Edit > Undo that removed the table left both floats on screen pointing at a detached cell, and clicking any of their items threw:

TypeError: Cannot destructure property 'path' of 'this.parent' as it is null.

In the desktop app that raises the "Unexpected error" dialog, and the edit is lost. Same shape as #5213 (quick-insert menu) and #5355 (table size grid).

Both selectItem handlers now act only while the cell is still in the document, and hide the float otherwise. The column toolbar already had a !block.parent guard, but it does not catch this case: TreeNode#remove clears only the removed table's own parent, so a cell inside it keeps its row — outMostBlock is the check that returns null once the subtree left the document.

Testing

packages/muya/e2e/tests/ui/table-tools-detached-5442.spec.ts — insert a table through the / grid, open each float, Undo the table away, then click every item: three row-menu items and six column-toolbar items. Each spec fails on develop (3 and 6 renderer errors) and passes here, with the document left unchanged. A third spec keeps the row menu editing a table that is still in the document.

pnpm -C packages/muya test (1823 passed), lint, lint:types, and the Chromium e2e suite all pass; the three inline/format-toolbar + inline/shortcuts triple-click failures on this machine reproduce on unmodified develop and are the known engine-dependent selection specs called out in playwright.config.ts.

🤖 Generated with Claude Code

Jocs and others added 2 commits September 18, 2026 12:22
…#5442)

The table row menu and the table column toolbar keep the cell they were
opened on. An Edit > Undo that removed the table left both floats on
screen pointing at a detached cell, and every item then threw "Cannot
destructure property 'path' of 'this.parent' as it is null" — the
"Unexpected error" dialog in the desktop app, with the edit lost.

Act only while that cell is still in the document, and hide the float
otherwise. The column toolbar's `!block.parent` guard did not catch this:
`TreeNode#remove` clears only the removed table's own parent, so a cell
inside it keeps its row and the guard passed.

Fixes #5442

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…5442)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Jocs
Jocs merged commit a3e4a64 into develop Sep 18, 2026
7 checks passed
@Jocs
Jocs deleted the fix/table-tools-detached-5442 branch September 18, 2026 04:36
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] Table row/column tools throw after Undo removes the table they point at

1 participant