Mindmap root node shows a "Delete Node" action that does nothing #214

Closed
opened 2026-05-21 13:17:11 +00:00 by AhmedHanafy725 · 1 comment
Member

Mindmap root node shows a "Delete Node" action that does nothing

Summary

Right-clicking the root node of a mindmap shows a "Delete Node" item in the context menu, but selecting it does nothing — the root is silently protected. This is misleading: the action appears available but has no effect.

Confirmed behavior (current code)

In crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.js:

  • showNodeContextMenu always appends a Delete Node item that calls deleteNode(group, nodeData), regardless of whether the node is the root.
  • deleteNode early-returns for the root: if (nodeData === state.tree) return; — so on the root it is a no-op (no delete, no feedback).

For comparison, keyboard delete is already consistent: in shortcuts.js, Delete/Backspace on the active node calls WhiteboardMindmap.deleteActive, which refuses the root and falls through so the generic handler deletes the whole mindmap object.

Desired behavior

Make the root's Delete meaningful and consistent with the keyboard path. Two acceptable options:

  1. Root context menu has no Delete item at all (only child nodes can be deleted), OR
  2. The root's Delete item deletes the whole mindmap object (relabelled, e.g. "Delete Mind Map"), matching the keyboard fall-through.

Recommended: option 2 — for the root, relabel the menu item to "Delete Mind Map" and delete the entire mindmap via WhiteboardObjects.deleteObject(group.id()) (the primitive used by WhiteboardTools.deleteSelected). This keeps the context menu and keyboard behavior consistent and removes the dead action. Non-root nodes keep "Delete Node".

Files

  • crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.jsshowNodeContextMenu (conditional Delete item by root vs non-root), and possibly deleteNode.

Acceptance criteria

  • Right-clicking the root no longer shows a Delete action that does nothing.
  • If the root offers Delete, it removes the entire mindmap (canvas + persistence), as one undo step where applicable.
  • Non-root nodes still show "Delete Node" and delete only that node and its subtree.
  • Keyboard Delete behavior is unchanged (still deletes the active node, or the whole mindmap on the root).
  • Locked mindmaps are unaffected (deletion still blocked when locked).

Notes

WhiteboardObjects.deleteObject(id) deletes a whole object by id and is exported; WhiteboardTools.deleteSelected and the keyboard path already use it. Keep the locked-object guard already present in deleteNode/showNodeContextMenu.

## Mindmap root node shows a "Delete Node" action that does nothing ### Summary Right-clicking the root node of a mindmap shows a "Delete Node" item in the context menu, but selecting it does nothing — the root is silently protected. This is misleading: the action appears available but has no effect. ### Confirmed behavior (current code) In `crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.js`: - `showNodeContextMenu` always appends a `Delete Node` item that calls `deleteNode(group, nodeData)`, regardless of whether the node is the root. - `deleteNode` early-returns for the root: `if (nodeData === state.tree) return;` — so on the root it is a no-op (no delete, no feedback). For comparison, keyboard delete is already consistent: in `shortcuts.js`, Delete/Backspace on the active node calls `WhiteboardMindmap.deleteActive`, which refuses the root and falls through so the generic handler deletes the whole mindmap object. ### Desired behavior Make the root's Delete meaningful and consistent with the keyboard path. Two acceptable options: 1. Root context menu has no Delete item at all (only child nodes can be deleted), OR 2. The root's Delete item deletes the whole mindmap object (relabelled, e.g. "Delete Mind Map"), matching the keyboard fall-through. Recommended: option 2 — for the root, relabel the menu item to "Delete Mind Map" and delete the entire mindmap via `WhiteboardObjects.deleteObject(group.id())` (the primitive used by `WhiteboardTools.deleteSelected`). This keeps the context menu and keyboard behavior consistent and removes the dead action. Non-root nodes keep "Delete Node". ### Files - `crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.js` — `showNodeContextMenu` (conditional Delete item by root vs non-root), and possibly `deleteNode`. ### Acceptance criteria - [ ] Right-clicking the root no longer shows a Delete action that does nothing. - [ ] If the root offers Delete, it removes the entire mindmap (canvas + persistence), as one undo step where applicable. - [ ] Non-root nodes still show "Delete Node" and delete only that node and its subtree. - [ ] Keyboard Delete behavior is unchanged (still deletes the active node, or the whole mindmap on the root). - [ ] Locked mindmaps are unaffected (deletion still blocked when locked). ### Notes `WhiteboardObjects.deleteObject(id)` deletes a whole object by id and is exported; `WhiteboardTools.deleteSelected` and the keyboard path already use it. Keep the locked-object guard already present in `deleteNode`/`showNodeContextMenu`.
Author
Member

Fix implemented and verified

Change

crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.js

  • showNodeContextMenu now branches the delete item by node:
    • Root node: a "Delete Mind Map" item that deletes the whole mindmap object.
    • Child nodes: unchanged "Delete Node" (removes the node and its subtree).
  • New deleteMindmap(group) helper mirrors WhiteboardTools.deleteSelected: detaches the group from the transformer, hides the properties panel, then calls WhiteboardObjects.deleteObject(group.id()) (which handles the undo snapshot, server sync, and connector cleanup).

The previous misleading state — a "Delete Node" item on the root that silently did nothing (deleteNode early-returns for the root) — is gone. The keyboard path is unchanged and already consistent (Delete on the active root deletes the whole mindmap).

Verification

  • cargo test --workspace --lib -> ok, 0 failed (no regression; JS-only change).
  • Served mindmap.js on the running service contains both Delete Mind Map and function deleteMindmap (deployed via release build + restart).

Manual check needed (no browser automation here)

Right-click the root -> menu shows "Delete Mind Map" and removes the whole mindmap. Right-click a child -> "Delete Node" removes just that node/subtree. Locked mindmaps remain protected.

## Fix implemented and verified ### Change `crates/hero_whiteboard_admin/static/web/js/whiteboard/mindmap.js` - `showNodeContextMenu` now branches the delete item by node: - Root node: a "Delete Mind Map" item that deletes the whole mindmap object. - Child nodes: unchanged "Delete Node" (removes the node and its subtree). - New `deleteMindmap(group)` helper mirrors `WhiteboardTools.deleteSelected`: detaches the group from the transformer, hides the properties panel, then calls `WhiteboardObjects.deleteObject(group.id())` (which handles the undo snapshot, server sync, and connector cleanup). The previous misleading state — a "Delete Node" item on the root that silently did nothing (`deleteNode` early-returns for the root) — is gone. The keyboard path is unchanged and already consistent (Delete on the active root deletes the whole mindmap). ### Verification - `cargo test --workspace --lib` -> ok, 0 failed (no regression; JS-only change). - Served `mindmap.js` on the running service contains both `Delete Mind Map` and `function deleteMindmap` (deployed via release build + restart). ### Manual check needed (no browser automation here) Right-click the root -> menu shows "Delete Mind Map" and removes the whole mindmap. Right-click a child -> "Delete Node" removes just that node/subtree. Locked mindmaps remain protected.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_whiteboard#214
No description provided.