Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

cancel a keyboard grab when Arrange mode ends, and scroll a stepped widget into view

[._.]/ Adam Eivyb6647a7d1569
diff --git a/client/src/components/dashboard/AGENTS.md b/client/src/components/dashboard/AGENTS.md
index 3abb1ac836..e984acc2b8 100644
--- a/client/src/components/dashboard/AGENTS.md
+++ b/client/src/components/dashboard/AGENTS.md
@@ -8,7 +8,7 @@ Dashboard widgets are registered in `widgetRegistry.jsx` — each entry has `{ i
**Height is measured, not declared.** `h` is NOT the rendered height. A cell measures its widget's natural height with a `ResizeObserver` and `packVertically` positions everything in pixels — each cell floats up to just below the nearest already-placed cell that shares a column. That's what stops an 80px card from reserving a 400px slot and leaving a band of dead whitespace across the row. `h` survives as the pre-measurement fallback (first paint) and as what an older client — which knows nothing about `fixedH` — reads out of a saved layout, so every drag commit refreshes it from the measurement via `withMeasuredHeights`. A cell whose height the user actually dragged carries `fixedH: true` and keeps `h` exactly, clipping content the way the whole grid used to; the ⌃⌄ handle (edit mode, pinned cells only) hands the height back to the content. `defaultH` in the registry is likewise only a first-paint ballpark.
-**The desktop handles are keyboard gestures too (#7263).** Move and resize are grab toggles, not pointer-only affordances: Enter/Space lifts the cell, the arrows step it, Enter/Space drops it and Escape puts it back — deliberately the same state machine dnd-kit gives the mobile reorder handle, so both feel like one feature. There is **one** placement path, not two: `beginGesture` freezes the same snapshot for either input, `stepGhost` snaps in the same units the pointer drag rounds to (a column; a rank or a row), `finishGesture` applies the same `applyGhost` and the same `fixedH` rule, and the preview a keyboard step draws IS the commit. Only where the next ghost comes from differs — a pixel delta, or one arrow press. The single divergence is deliberate: a horizontal *move* step leaves `order` alone, where the drag re-derives it from `rankAtPixel` every frame, so ↑/↓ owns the sequence outright and no press has a second effect the user can't see coming. The grid's `role="status"` region narrates each step (the drag doesn't narrate — it's already visible to whoever is doing it), and `aria-pressed` carries grabbed/idle. **A new handle wired with `onPointerDown` alone is a WCAG 2.1.1 failure**, not a nice-to-have: it announces an action through its `aria-label` and then does nothing, which reads as broken rather than unavailable. `DashboardGrid.test.jsx` fails on any `<DragHandle>` in the source that takes `onPointerDown` without `onKeyDown`.
+**The desktop handles are keyboard gestures too (#7263).** Move and resize are grab toggles, not pointer-only affordances: Enter/Space lifts the cell, the arrows step it, Enter/Space drops it and Escape puts it back — deliberately the same state machine dnd-kit gives the mobile reorder handle, so both feel like one feature. There is **one** placement path, not two: `beginGesture` freezes the same snapshot for either input, `stepGhost` snaps in the same units the pointer drag rounds to (a column; a rank or a row), `finishGesture` applies the same `applyGhost` and the same `fixedH` rule, and the preview a keyboard step draws IS the commit. Only where the next ghost comes from differs — a pixel delta, or one arrow press. The single divergence is deliberate: a horizontal *move* step leaves `order` alone, where the drag re-derives it from `rankAtPixel` every frame, so ↑/↓ owns the sequence outright and no press has a second effect the user can't see coming. The grid's `role="status"` region narrates each step (the drag doesn't narrate — it's already visible to whoever is doing it), and `aria-pressed` carries grabbed/idle. **A new handle wired with `onPointerDown` alone is a WCAG 2.1.1 failure**, not a nice-to-have: it announces an action through its `aria-label` and then does nothing, which reads as broken rather than unavailable. `DashboardGrid.test.jsx` fails on any `<DragHandle>` in the source that takes `onPointerDown` without `onKeyDown`. **A keyboard grab is modal, which a pointer drag is not** — it stays open until the user acts, so anything that can end Arrange mode under it has to cancel it explicitly: unmounting a focused handle (Save/Cancel, or a rotation crossing the breakpoint) fires no blur, and the abandoned ghost would go on overriding the preview so the grid draws a placement the user already cancelled. One effect watching `editable`/`isMobile` owns that.
**Mobile editing.** Free-form move/resize is desktop-only (a phone has no room for positional editing), but *reordering* works on mobile: edit mode swaps the two grid handles for a single reorder handle. The 1-D sort goes through **`@dnd-kit/sortable`** — the same `PointerSensor` + `KeyboardSensor` + `verticalListSortingStrategy` pairing as `cos/tabs/TasksTab.jsx` and `universeBuilder/InfluenceChipsInput.jsx` — which is what supplies touch, keyboard (space to lift, arrows to move), multi-pointer safety, screen-reader announcements and edge auto-scroll. **Do not hand-roll a pointer gesture for this**; the free-form 2-D drag stays hand-rolled only because arbitrary grid placement is not what a sortable list does. Use `dndTransformToCss` from `client/src/lib/dndTransform.js` in the style object, never `@dnd-kit/utilities`.
diff --git a/client/src/components/dashboard/DashboardGrid.jsx b/client/src/components/dashboard/DashboardGrid.jsx
index 0ae1e8cca1..7030219be5 100644
--- a/client/src/components/dashboard/DashboardGrid.jsx
+++ b/client/src/components/dashboard/DashboardGrid.jsx
@@ -793,6 +793,28 @@ export default function DashboardGrid({ items, editable, onChange, onLayoutModeC
setAnnouncement(`${widgetLabel(item)} returned to its original position.`);
}, [finishGesture]);
+ // A keyboard grab is modal, so it can still be open when the grid leaves the
+ // mode that offers it — Save/Cancel on the Arrange toolbar, or a rotation
+ // crossing the mobile breakpoint. The handles simply unmount, which fires no
+ // blur, so without this the abandoned ghost keeps overriding the preview and
+ // the grid goes on drawing a placement the user already cancelled.
+ useEffect(() => {
+ if (editable && !isMobile) return;
+ if (dragRef.current) finishGesture(false);
+ }, [editable, isMobile, finishGesture]);
+
+ // The handle keeps focus while the cell travels under it, so the browser has
+ // no focus change to scroll to — stepping a widget down a tall dashboard
+ // would otherwise walk it past the fold with nothing to look at. `nearest`
+ // is a no-op while the cell is already on screen. Keyboard only: a pointer
+ // drag is anchored to a cursor the user can already see.
+ useEffect(() => {
+ if (!drag?.keyboard) return;
+ containerRef.current
+ ?.querySelector(`[data-widget-id="${drag.ghost.id}"]`)
+ ?.scrollIntoView?.({ block: 'nearest' });
+ }, [drag, containerRef]);
+
useEffect(() => {
// A keyboard grab drives itself from the handle's own keydown — installing
// the window pointer listeners for it would let a click anywhere on the
diff --git a/client/src/components/dashboard/DashboardGrid.test.jsx b/client/src/components/dashboard/DashboardGrid.test.jsx
index 58aa3165ff..ac065e48a5 100644
--- a/client/src/components/dashboard/DashboardGrid.test.jsx
+++ b/client/src/components/dashboard/DashboardGrid.test.jsx
@@ -649,6 +649,49 @@ describe('DashboardGrid keyboard arrange', () => {
expect(fireEvent.keyDown(handle, { key: 'Tab' })).toBe(true);
});
+ // A grab is modal, so it survives until something ends it — and leaving
+ // Arrange mode unmounts the handle without firing a blur. An abandoned ghost
+ // there keeps overriding the preview, so the grid draws a placement the user
+ // just cancelled.
+ it('drops a grab when the grid leaves Arrange mode', () => {
+ const onChange = vi.fn();
+ const { rerender } = render(
+ <DashboardGrid
+ items={NARROW}
+ editable
+ onChange={onChange}
+ renderItem={(item) => <div data-testid={`widget-${item.id}`}>{item.id}</div>}
+ />
+ );
+ const handle = screen.getByLabelText('Move a');
+ handle.focus();
+ fireEvent.keyDown(handle, { key: 'Enter' });
+ fireEvent.keyDown(handle, { key: 'ArrowRight' });
+
+ rerender(
+ <DashboardGrid
+ items={NARROW}
+ editable={false}
+ onChange={onChange}
+ renderItem={(item) => <div data-testid={`widget-${item.id}`}>{item.id}</div>}
+ />
+ );
+ expect(onChange).not.toHaveBeenCalled();
+ // The ghost is gone, so the cell is drawn where the saved layout puts it.
+ expect(cellFor('a').style.left).toBe('0px');
+
+ // Re-entering Arrange finds an idle handle, not a grabbed one.
+ rerender(
+ <DashboardGrid
+ items={NARROW}
+ editable
+ onChange={onChange}
+ renderItem={(item) => <div data-testid={`widget-${item.id}`}>{item.id}</div>}
+ />
+ );
+ expect(screen.getByLabelText('Move a')).toHaveAttribute('aria-pressed', 'false');
+ });
+
// ⌘← is browser navigation, ⌥↑ is a text jump — a chord is never a step.
it('leaves modifier chords to the browser', () => {
const onChange = renderGrid(NARROW);