Whiteboard: z-order operations and frame slide reorder are not undoable #188
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#188
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?
Problem
Every z-index reorder fires
WhiteboardSync.onUpdate(...)to persist but never brackets the change withWhiteboardHistory.snapshotBefore+commitUpdate, so Ctrl+Z does nothing for any of these:static/web/js/whiteboard/tools.js:944-977(toolbar / shortcut path) andstatic/web/js/whiteboard/contextmenu.js:197-217(right-click menu).static/web/js/whiteboard/frames.js:66-80(_swapOrder). The selection toolbars chevrons and the right-click context menu both call this; the user can move a slide up or down in the presentation deck and have no way to undo it.Approach
Same pattern as the other history-coverage fixes:
frameOrderchange.WhiteboardHistory.batch(...)so Ctrl+Z reverses the whole group in one step.WhiteboardSync.onUpdate(node)broadcast.Acceptance
_swapOrderfrom any caller) → Ctrl+Z swaps the two framesframeOrderback. Slide badges update.onUpdatestill fires exactly once per affected node per op. No double-emit.Implementation Spec for Issue #188
Files to Modify
static/web/js/whiteboard/tools.jsstatic/web/js/whiteboard/contextmenu.jsstatic/web/js/whiteboard/frames.jsPattern
For each z-order op (single or multi-node):
WhiteboardHistory.batch(history.js:43) folds the per-node commits into a single undo step. For single-node ops the batch is harmless (one push inside).Implementation Plan
Step 1:
tools.js:944-977—bringToFront / sendToBack / moveForward / moveBackwardEach function gets
snapshotBeforeovertransformer.nodes()at the top and a batchedcommitUpdateloop before the existingonUpdatebroadcast.Step 2:
contextmenu.js:197-217— right-clickbringToFront / sendToBackSingle-node path. Add
snapshotBefore(targetNode.id())at the top after the early-exit, andcommitUpdate(targetNode.id())afterbatchDraw()but beforeWhiteboardSync.onUpdate(targetNode). No batch wrapper needed (single node).Step 3:
frames.js:_swapOrder(lines 66-80) — slide reorderSnapshot both
aandbbefore thesetAttrcalls; commit both after theredrawAllFrameBadges, wrapped in a singlebatchso one Ctrl+Z reverses the swap.Acceptance Criteria
onUpdatefires once per affected node.Notes
snapshotreadsz_indexviaserializeForServer(sync.js:382:z_index: node.zIndex() || 0). For frames it also capturesframeOrder(sync.js:314-318). Both are restored byapplySyncUpdate(sync.js:580-582forz_index; the frame branch atsync.js:670-676restoresframeOrder). So undo restores the visual ordering correctly.WhiteboardHistory.batchis no-op for single-node use cases — one push goes into the batch, applyUndo just unwraps it.Test Results + Final Summary
Changes
static/web/js/whiteboard/tools.js: added_applyZOrder/_commitZOrderhelpers; wrappedbringToFront,sendToBack,moveForward,moveBackward. Multi-node selection commits are batched.static/web/js/whiteboard/contextmenu.js: single-nodebringToFront/sendToBacknow snapshot before + commit after.static/web/js/whiteboard/frames.js:_swapOrdersnapshots bothaandbbefore theframeOrderswap and commits both in a batch.Behaviour after fix
_swapOrder) → Ctrl+Z swaps both back, slide badges update.onUpdatefires once per affected node, no double-emit.Gates
node -c tools.js / contextmenu.js / frames.js— JS syntax OKcargo fmt --check— passcargo clippy --workspace --all-targets -- -D warnings— passManual verification still required
Rebuild + restart
hero_whiteboard_admin, hard-reload. Walk through each op (single + multi-node) and confirm Ctrl+Z / Ctrl+Y behave correctly. Verify frame slide reorder via the selection toolbar chevrons in particular.