fix: undo closing a widget (#40) #48
Reference in New Issue
Block a user
Delete Branch "ai/issue-40-undo-closing-a-widget"
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
Closing a widget was instant and destructive:
GridStackItem.close()detached the item and there was no way back short of a full layout reset (which also throws away every other widget's placement).Fix
GridStackItem.CloseEventnow carries the item'sPosition(id, x, y, w, h), captured right beforeremoveFromParent()— after detach the grid no longer reports it.DashboardViewwires every widget's close listener once, on first add (addWidgetToGrid), toofferUndo: for a client-initiated close (isFromClient()), it shows aNotificationtoast with an "Undo" button that re-adds the very sameGridStackIteminstance at its captured position, so it keeps its exactgs-id/size/position rather than the grid's next free slot.GridStackItem#close(), e.g. duplicate cleanup) havefromClient == falseand are skipped — no toast.gridstack.closed,gridstack.undo) inde/en/es.Tests
DashboardViewTest: toast shown on close, undo restores position/id, repeated close→undo→close still offers undo, programmatic close shows no toast.WidgetUndoClosePlaywrightTest(e2e): close → undo → exact grid slot restored, in a real browser../mvnw test: 73/73 green.Closes #40