Skip to content

The agent that grows with you

fix(desktop): gateway/profile group headers take the pointer activator only

kshitijk4poor15a256293d14
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
index 68dc2e85e75..bfaaf4dfbf6 100644
--- a/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
@@ -16,9 +16,11 @@ import { ChatSidebar } from './index'
// Gateway/profile groups reorder by drag as well as by the ⋯ menu's Move
// up/down. The grab handle only reveals itself on hover, so the visible
-// affordance is the header itself: a press on the label must arm the dnd
-// sortable (the lead handle already did). Proven red on the version where only
-// the handle carried the listeners.
+// affordance is the header itself: a POINTER press on the label must arm the
+// dnd sortable (the lead handle already did). Only the pointer activator lives
+// on the header, though — the keyboard activator stays on the grabber, or
+// Space on the ⋯ button would arm a reorder and swallow the next Space in the
+// rename dialog (#83617).
const noop = () => {}
@@ -48,7 +50,7 @@ afterEach(() => {
$gatewayGroupOrder.set([])
})
-it('reorders gateway sections by dragging the header label, not only the grab handle', async () => {
+const arrange = () => {
mount()
act(() => {
$connectionsRegistry.set({
@@ -75,22 +77,45 @@ it('reorders gateway sections by dragging the header label, not only the grab ha
const device = screen.getByText('This device').closest('[data-gateway-section]') as HTMLElement
expect(sectionIds()).toEqual([JSON.stringify(['gateway', 'remote-1']), JSON.stringify(['gateway', 'local'])])
- // dnd-kit's KeyboardSensor: Space on the focused sortable arms the drag,
- // ArrowUp moves it over the previous item, Space drops. Drives the same
- // listeners the pointer path binds, without needing layout in jsdom.
- // The fold link, not the row (which dnd-kit also names as a sortable button).
+ return { device, sectionIds }
+}
+
+it('arms the reorder from a pointer press on the header label', async () => {
+ const { device } = arrange()
+ // Pointer path: a press on the fold label plus a move past the 6px
+ // activation distance arms the sortable (jsdom has no layout, so the drop
+ // itself cannot resolve a target here — arming is the assertion).
const label = within(device).getByRole('button', { expanded: true, name: 'This device' })
- label.focus()
await act(async () => {
- fireEvent.keyDown(label, { code: 'Space', key: ' ' })
+ fireEvent.pointerDown(label, { button: 0, clientX: 10, clientY: 10, isPrimary: true, pointerId: 1 })
+ fireEvent.pointerMove(document, { clientX: 10, clientY: 30, pointerId: 1 })
+ await Promise.resolve()
+ })
+ expect(device.querySelector('[data-glass-opaque]')).not.toBeNull()
+ await act(async () => {
+ fireEvent.pointerUp(document, { clientX: 10, clientY: 30, pointerId: 1 })
+ await Promise.resolve()
+ })
+ expect(device.querySelector('[data-glass-opaque]')).toBeNull()
+})
+
+it('reorders gateway sections from the grabber by keyboard', async () => {
+ const { device, sectionIds } = arrange()
+ // Keyboard path: Space on the focused grabber arms the drag, ArrowUp moves it
+ // over the previous item, Space drops. Drives the same listeners without
+ // needing layout in jsdom.
+ const grabber = device.querySelector<HTMLElement>('[data-reorder-handle]')!
+ grabber.focus()
+ await act(async () => {
+ fireEvent.keyDown(grabber, { code: 'Space', key: ' ' })
await Promise.resolve()
})
await act(async () => {
- fireEvent.keyDown(label, { code: 'ArrowUp', key: 'ArrowUp' })
+ fireEvent.keyDown(grabber, { code: 'ArrowUp', key: 'ArrowUp' })
await Promise.resolve()
})
await act(async () => {
- fireEvent.keyDown(label, { code: 'Space', key: ' ' })
+ fireEvent.keyDown(grabber, { code: 'Space', key: ' ' })
await Promise.resolve()
})
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx
index 331d43ef679..592e983a62e 100644
--- a/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups.tsx
@@ -192,8 +192,10 @@ function GatewayProfileGroup({
// glyph only reveals its grabber on hover, so a press anywhere on the
// row must start the reorder too. The ⋯/caret cluster and the handle
// keep their own gestures; a sub-threshold press on the label is still
- // the click that folds the group.
- {...sortable.dragHandleProps}
+ // the click that folds the group. Pointer activator only (forwarded
+ // below): the keyboard activator stays on the grabber, or Space on the
+ // ⋯ button would arm a reorder and swallow the next Space in the
+ // rename dialog (#83617).
actions={
<div className="flex items-center">
{group.profile && (
diff --git a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
index 2fe55edeb08..db1a23af9a2 100644
--- a/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/session-row.test.tsx
@@ -492,7 +492,8 @@ describe('SidebarSessionRow inside the sortable list', () => {
const kebab = screen.getByRole('button', { name: 'Session actions' })
kebab.focus()
- // Not defaultPrevented: dnd-kit's activator never saw it.
+ // Not defaultPrevented (the ⋯ menu is stubbed in this file, so only
+ // dnd-kit could have claimed the key) and no grabber reports a drag.
expect(fireEvent.keyDown(kebab, space)).toBe(true)
expect(container.querySelector('[aria-pressed="true"]')).toBeNull()
})