fix: let a mind map close back up when a node is deleted (#513) - #522
Merged
Conversation
Adding a node shoves its siblings aside and re-flows the tree (#273). Deleting one did not, so the survivors kept the spacing of a tree they were no longer in — delete two of three children and the last one stayed where the other two had pushed it. Every delete path now routes through one settle step, so it does not matter whether a node leaves by the mind-map Delete key, a plain shape delete, or a mixed whiteboard selection. The trees to settle are read BEFORE the removal — a node that is already gone cannot name the tree it was in — and each distinct tree re-flows once however many of its nodes went. A deleted root contributes nothing, which is right: its whole tree left with it. The settle runs inside the caller's commit(), so delete-and-settle is one undo step. deleteMindmapSubtrees also left the deleted ids in state.selection; the shared removal it now calls clears them. No new layout logic. The existing balanced layout already spaces a level by the real boxes — it was only never asked to run. Closes #513 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Deleting two of three child nodes left the last one where the other two had pushed it, instead of moving back toward its parent.
Cause
Adding a node shoves its siblings aside and re-flows the tree — the auto-tidy of #273. Deleting one had no matching call, so the survivors kept the spacing of a tree they were no longer in.
Verified before building it
The issue asked to confirm the scope, since the report also asked for level-spacing logic. Reflowing on delete is enough:
mindmapLayoutPatchesalready spaces a level against the real measured boxes (#427 item 8), so no layout work was needed — the layout was simply never asked to run. The added test pins the numbers: the survivor sat 65.5px off the root's centre line before and after the delete; it now moves in.The fix
One settle step that every delete path routes through, so it does not matter how a node leaves:
deleteMindmapSubtreesremoveShapesremoveSelectionOrIdsremoveWhiteboardSelectionTwo details the issue called out, both handled:
reflowTreesettles a whole tree from any one member, so N members of one tree would be N identical re-flows. Trees already settled are tracked by their component set.fitMindmapNodeshad the same per-id loop and now shares the deduped helper.The settle runs inside the caller's
commit(), so delete-and-settle is one undo step.Also fixed in passing
deleteMindmapSubtreesfilteredshapesandconnectorsbut neverstate.selection, so deleted ids stayed selected. The shared removal it now calls clears them. Covered by a test.Tests
Six, in
useDiagramStore.freefloating.test.js. Three of them fail onmain:removeShapessettles too, not only the mind-map Delete key (the regression, via the other path)Full suite green: 1458 tests.
Closes #513
🤖 Generated with Claude Code