fix: make dashboard widgets closable (#14) #17

Merged
pitfriedrich merged 1 commits from ai/issue-14-closable-widgets into main 2026-07-26 18:20:27 +00:00
Collaborator

Closes #14

What

Every GridStackItem now renders a close button (fa-xmark) in its top-right corner, next to the drag grip — same hover/focus affordance, same corner slot, with the grip stepping aside (right: 48px) only when a close button is present.

  • GridStackItem#close() detaches the item from its layout and fires a CloseEvent; grid-stack.ts already unregisters removed widgets via its MutationObserver, so the saved layout updates without any new client protocol.
  • Closable is on by default; setClosable(false) hides the button (isClosable(), getCloseButton() alongside the existing getDragHandle()).
  • New gridstack.close translation key (de/en/es), plus the hint text now mentions closing.

Also

Per follow-up request: the "Letztes entfernen" / "Remove last" toolbar button in GridStackView is gone — per-widget close replaces it. The view no longer keeps a Deque of added widgets, and its widget counter only ever grows so a closed widget's gs-id is never handed to a new widget (which would otherwise inherit the closed one's saved position).

Tests

./mvnw test — 5/5 green. GridStackViewTest covers add-then-close, close-removes-only-the-clicked-item, the CloseEvent listener, and setClosable(false). The click tests fire a real DOM click at the button so its wiring is covered, not just the server-side close() API.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq

Closes #14 ## What Every `GridStackItem` now renders a close button (`fa-xmark`) in its top-right corner, next to the drag grip — same hover/focus affordance, same corner slot, with the grip stepping aside (`right: 48px`) only when a close button is present. - `GridStackItem#close()` detaches the item from its layout and fires a `CloseEvent`; `grid-stack.ts` already unregisters removed widgets via its `MutationObserver`, so the saved layout updates without any new client protocol. - Closable is on by default; `setClosable(false)` hides the button (`isClosable()`, `getCloseButton()` alongside the existing `getDragHandle()`). - New `gridstack.close` translation key (de/en/es), plus the hint text now mentions closing. ## Also Per follow-up request: the **"Letztes entfernen" / "Remove last"** toolbar button in `GridStackView` is gone — per-widget close replaces it. The view no longer keeps a `Deque` of added widgets, and its widget counter only ever grows so a closed widget's `gs-id` is never handed to a new widget (which would otherwise inherit the closed one's saved position). ## Tests `./mvnw test` — 5/5 green. `GridStackViewTest` covers add-then-close, close-removes-only-the-clicked-item, the `CloseEvent` listener, and `setClosable(false)`. The click tests fire a real DOM `click` at the button so its wiring is covered, not just the server-side `close()` API. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq
claude-bot added 1 commit 2026-07-26 18:17:20 +00:00
fix: make dashboard widgets closable (#14)
CI / build-and-test (pull_request) Successful in 1m27s
7d23eef81b
Every GridStackItem now renders a close button next to its drag grip,
mirroring the grip's hover affordance. Closing detaches the item
server-side; grid-stack.ts already unregisters widgets via its
MutationObserver, so the layout is persisted without an extra protocol.

Closable is on by default and can be turned off per item with
setClosable(false); GridStackItem.CloseEvent lets views react.

The GridStackView "remove last" toolbar button is dropped — per-widget
close replaces it, so the view no longer tracks a widget stack. Its
counter now only grows, keeping a closed widget's id from being handed
to a new widget (which would inherit the saved position).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9ZtWUBQF4SuSHpzZ3zwq
pitfriedrich requested review from pitfriedrich 2026-07-26 18:18:25 +00:00
pitfriedrich marked the pull request as work in progress 2026-07-26 18:18:28 +00:00
pitfriedrich marked the pull request as ready for review 2026-07-26 18:19:37 +00:00
pitfriedrich merged commit 4de757df99 into main 2026-07-26 18:20:27 +00:00
pitfriedrich deleted branch ai/issue-14-closable-widgets 2026-07-26 18:20:27 +00:00
Sign in to join this conversation.