fix(site): prevent duplicate menu when right-clicking chat kebab (#28391)

Right-clicking the kebab (⋮) button on a chat in the agents sidebar was
showing two menus: the kebab's own dropdown **and** the row-level
right-click context menu.

The kebab lives inside the row's \`ContextMenuTrigger\`, so the
\`contextmenu\` event on the button bubbles up and opens the row's
context menu on top of the dropdown that the button already owns.

Fix: swallow \`contextmenu\` on the kebab \`Button\` so only its
dropdown is associated with the button. Right-clicking anywhere else on
the row still opens the row context menu as before.

> Generated with Coder Agents on behalf of @tracyjohnsonux.

---------

Co-authored-by: Coder Agents <noreply@coder.com>
This commit is contained in:
TJ
2026-08-20 15:56:36 +00:00
committed by GitHub
co-authored by Coder Agents
parent 05b78a0902
commit e58a603949
@@ -339,6 +339,22 @@ export const ChatTreeNode: FC<ChatTreeNodeProps> = ({ chat, isChildNode }) => {
isActiveChat && "opacity-100",
)}
aria-label={`Open actions for ${chat.title}`}
onContextMenuCapture={(e) => {
e.preventDefault();
e.stopPropagation();
}}
onMouseDownCapture={(e) => {
if (e.button === 2) {
e.preventDefault();
e.stopPropagation();
}
}}
onPointerDownCapture={(e) => {
if (e.button === 2) {
e.preventDefault();
e.stopPropagation();
}
}}
>
<EllipsisVerticalIcon className="size-3.5" />
</Button>
@@ -346,6 +362,14 @@ export const ChatTreeNode: FC<ChatTreeNodeProps> = ({ chat, isChildNode }) => {
<DropdownMenuContent
align="end"
className="[&_[role=menuitem]]:text-[13px]"
// The dropdown is portaled to the body, but React
// portals bubble events through the React tree, so a
// right-click inside the menu would still reach the
// row's context-menu trigger and open a duplicate menu.
onContextMenu={(e) => {
e.preventDefault();
e.stopPropagation();
}}
>
<ChatActionsMenuItems
{...sharedMenuItemProps}