Mind map selection outline does not update on collapse/expand #157
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#157
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the user toggles collapse/expand on a mind-map node (the +/− indicator) or on the root via the keyboard shortcut, the underlying tree re-renders with a different size, but the selection outline / transformer bounding box does not refresh — it keeps the old extents from before the toggle.
Expected
After
renderMindmap(group), the transformer attached to the mindmap (if any) should recompute its bounding box (tr.forceUpdate()in Konva terms) so the selection outline matches the new visual extents.Actual
The outline keeps the old size, and dragging the corner handles operates on stale dimensions.
Repro
Notes
The relevant code path is
indicator.on("click tap", ...)inmindmap.js(setsnode.collapsedand callsrenderMindmap(group)), as well astoggleCollapseRootfor the root-level shortcut. After the redraw, the transformer needs to be told to refresh — pattern used elsewhere is something likeWhiteboardObjects.refreshTransformer(group)ortr.forceUpdate(). Verify how other re-rendering mutations (e.g.,flipDirection,addChildToNode,deleteNode) handle the transformer.Implementation Spec
Root cause
renderMindmap(group)inmindmap.jscallsgroup.destroyChildren()and rebuilds the sub-tree, which changes the group's bounding box. AKonva.Transformercaches its attached nodes' bounding boxes, so the selection outline keeps the old extents until something callstr.forceUpdate().Three mutating paths already do the refresh inline (
addChildToNode~L463–466,flipDirection~L493–496,deleteNode~L681–686). But several other paths skip it:indicator.on('click tap', …)toggleCollapseRooteditMindmapNodeblureditMindmapTitleblurshowCommentPopupSave / RemoveApproach: refresh inside
renderMindmaprenderMindmapis the single point through which every mutating path funnels. OneforceUpdate()at the end covers all current sites and any future ones. This mirrors the existing pattern inobjects.jswhererefreshTransformerFor(group)is called from every re-render helper. The cost is a no-op when the mindmap isn't selected (tr.nodes().indexOf(group) >= 0guard), so no flicker risk.Files to Modify
crates/hero_whiteboard_ui/static/web/js/whiteboard/mindmap.js— only file.Implementation Plan
Step 1 — add helper + single call from
renderMindmapmeasureNodeText):renderMindmap, afterWhiteboardCanvas.getObjectLayer().batchDraw();:forceUpdateblocks inaddChildToNode,flipDirection, anddeleteNodeso the file is tight and consistent withobjects.js.Dependencies: none.
Acceptance Criteria
With a mindmap selected (transformer attached):
−/+on any non-root node — selection outline tracks the contracted/expanded extent in the same frame.toggleCollapseRootkeyboard shortcut — outline tracks new bounds.+— outline grows.What NOT to break
c40d249lock work — gates run beforerenderMindmap, so locked behavior is unchanged.92f9859menu unification — not touched.e3c4cb8per-node contextmenu wiring — not touched.measureNodeText,layoutTree,assignDepthAxis,getLayoutBounds, wrap mode) — not touched. Only adds a single line at the tail ofrenderMindmap.WhiteboardSync.onUpdate/WhiteboardHistory—forceUpdate()only refreshes transformer handles; it does not emittransform/transformendevents that would loop into sync.Validation
cargo check --workspacecargo test --workspace --libforceUpdatereferencesImplementation summary
Changes
crates/hero_whiteboard_ui/static/web/js/whiteboard/mindmap.js— added a privaterefreshTransformerFor(group)helper and call it once at the tail ofrenderMindmap(afterbatchDraw). The helper short-circuits when the mindmap isn't currently selected, so the cost is zero on unselected mindmaps. Removed three inlineforceUpdateblocks inaddChildToNode,flipDirection, anddeleteNodesince they're now redundant.Every mutating path that calls
renderMindmapnow refreshes the transformer automatically: collapse/expand toggle on any node (the reported bug),toggleCollapseRootkeyboard shortcut, direction flip, add child, delete node, node text edit blur, title text edit blur, and comment popup Save/Remove.Validation
cargo check --workspace: passcargo test --workspace --lib: passNotes
UI-only change. Verify visually by selecting a mindmap (transformer handles appear), then clicking any +/− toggle — the selection outline should contract/expand to match the new layout instantly. Unselected mindmaps behave exactly as before.