Repository navigation
fix(site/src/pages/AgentsPage): add click alternatives to dragging in the agents sidebar - #32670
Conversation
…sidebar resize and pin reorder drags
…its story at the handle
chrifro
left a comment
There was a problem hiding this comment.
Round 1. The pin reorder alternative is solid: Move up and Move down share movePinnedChat with the drop path, child rows and filtered views get no items, and the Vitest coverage hits the mutation. One should-fix on the resize alternative, inline below.
[should-fix] On touch and pen, long-press never opens the "Sidebar width" menu, though the PR body says it does. Details and a fix are inline on ResizableChatsSidebarFrame.tsx:135.
Nits (optional):
ResizableChatsSidebarFrame.tsx:20:MENU_RESIZE_STEPcould live insidebarWidth.tsnext toLEFT_SIDEBAR_KEYBOARD_RESIZE_STEPand be exported, soResizableChatsSidebarFrame.test.tsx:101-102uses it instead of a hardcoded64.- At the limits, the width menu disables its items but the pin menu hides them. Either is fine; one convention reads better.
ChatTreeNode.tsx:51-52: the new props lack the "When omitted, the item is hidden" doc thatChatActionsMenuItemshas.AgentsPageLayout.stories.tsx:768: if the wait is needed for the portaled menu,screen.findByRole("menuitem", { name: "Reset width" })reads better thanwithin(document.body).findByText.
Follow-up filed (pre-existing, not blocking): DEQ-652: the resize handle is a 4px pointer target (2.5.8).
🤖 Generated by Coder Agents on behalf of @chrifro.
| /> | ||
| {/* The menu is the single-pointer alternative to dragging (WCAG 2.5.7). */} | ||
| <ContextMenu> | ||
| <ContextMenuTrigger asChild> |
There was a problem hiding this comment.
[should-fix] Long-press can't open this menu on touch or pen. ContextMenuTrigger asChild composes its onPointerDown after the child's, and Radix's composeEventHandlers skips its long-press timer when event.defaultPrevented is set. handlePointerDown (line 65) calls e.preventDefault() for every primary button-0 pointer, which includes touch and pen. So the menu opens only with a right-click, and on a tablet at sm+ width there is still no single-pointer alternative to the drag (2.5.7). The PR body's "or long-press" claim is also wrong.
I checked this locally with a throwaway Vitest probe: a touch or pen pointerDown plus 1s of fake timers leaves the menu closed. With isPrimary: false, which skips the drag handler, the same press opens it.
Suggested fix: call e.preventDefault() only for e.pointerType === "mouse". The handle is already touch-none, so touch needs no preventDefault, and Radix clears the long-press timer on pointermove, so a real drag won't pop the menu. Please add a Vitest case for touch long-press, and drop the long-press claim if you go another way.
There was a problem hiding this comment.
Fixed in 48b26b1 and 22e8afb. handlePointerDown now calls preventDefault only when pointerType === "mouse", so Radix starts its long-press timer for touch and pen. I added a touch and pen Vitest case: it long-presses, picks Increase width, and checks the saved width. It fails with the old preventDefault.
The second commit covers an edge case: a finger that rests for 700ms and then moves would open the menu while still resizing under it. The ContextMenu's onOpenChange(true) now ends the drag. The same test moves the pointer after the menu opens and fails without that guard.
🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.
…and pen long-press
…rag when the width menu opens
|
@chrifro could you take another look? Round 2 is up at 22e8afb and CI is green.
🤖 Generated by Coder Agents on behalf of @bartekgatzcoder. |
chrifro
left a comment
There was a problem hiding this comment.
Round 2 at 22e8afb fixes the touch/pen long-press: preventDefault now runs only for mouse, and opening the menu ends the drag. I verified both in Storybook (mouse right-click and left-drag, a touch long-press that opens the width menu, and a touch drag that resizes without it), along with Move up and Move down in the pinned chat menu. The 188 ChatsSidebar Vitest tests pass, and frontend-review and frontend-deep-review found nothing blocking or should-fix. Nit: LEFT_SIDEBAR_MENU_RESIZE_STEP in sidebarWidth.ts uses a // comment, not JSDoc, which matches the file. Follow-ups: none new (DEQ-652 already covers the 4px target).
🤖 Generated by Coder Agents on behalf of @chrifro.
The agents sidebar had two interactions that needed a drag, with no single-pointer alternative (WCAG 2.5.7 Dragging Movements). This PR adds one for each and leaves the drags as they are:
reorderPinnedChatmutation through the handler the drop path now shares, so the optimistic order and the error toast behave the same as for a drag. The items are hidden while filters disable reordering, as dragging already is.Closes DEQ-147
ResizableChatsSidebarFrame: resize separator of the agents sidebarChatActionsMenuItems/SortableChatTreeNode: Pinned section of the agents sidebarOpen UX question (the ticket is labeled
ux-input-needed). The resize menu works and meets 2.5.7, but nothing on screen tells users it exists: it only opens with a right-click or long-press on a 4px handle. If design would rather have a visible control, for example width presets in a sidebar menu, that can replace this menu.Tests: Vitest covers Move up and Move down sending the right
pin_order, and each resize menu item persisting the new width. NewReorderPinMenuandResizableSidebarContextMenustories capture the open menus, including Decrease width disabled at the minimum width.Dropped review findings
scopetoreorderPinnedChatso overlapping reorders run in order. Dropped because the menu closes after each move, and fast keyboard drags already send absolute orders through the same unscoped mutation. It is a separate change to shared query code.Grouping and decision log
ContextMenuprimitive and adds no permanent UI, so I chose it and raised discoverability above as the open UX question.mainand appear on both base and branch:color-contraston the faded relative timestamp in chat rows, andaria-hidden-focuson#storybook-rootwhenever any Radix context menu is open, including the existing chat-row context menu.preventDefaultonly for mouse. Calling it for touch and pen cancelled Radix's long-press timer, and the handle is alreadytouch-none. Opening the menu ends any drag in progress, so a press that is held and then moved does not keep resizing under the menu.sidebarWidth.ts(LEFT_SIDEBAR_MENU_RESIZE_STEP), restored the prop docs onChatTreeNode, and switched the story wait toscreen.findByRole. I kept different conventions at the limits on purpose. The width menu always has the same three items, so a disabled step tells the user it has reached a limit. The pin menu hides Move up and Move down, the same way it already hides Pin or Unpin when they don't apply.🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.