diff --git a/ui/src/pages/CompanySkills.test.tsx b/ui/src/pages/CompanySkills.test.tsx index c22c37ee847..26993e4ad6d 100644 --- a/ui/src/pages/CompanySkills.test.tsx +++ b/ui/src/pages/CompanySkills.test.tsx @@ -51,6 +51,9 @@ vi.mock("@/components/ui/dropdown-menu", () => ({ ), DropdownMenuSeparator: () =>
, + DropdownMenuSub: ({ children }: { children: ReactNode }) => <>{children}, + DropdownMenuSubContent: ({ children }: { children: ReactNode }) =>
{children}
, + DropdownMenuSubTrigger: ({ children }: { children: ReactNode }) => , DropdownMenuTrigger: ({ children }: { children: ReactNode }) => <>{children}, })); @@ -326,6 +329,47 @@ describe("DiscoveryGrid Studio entry points", () => { expect(onCreate).toHaveBeenCalledTimes(2); }); + + it("does not open a skill when keyboard-activating its actions button", async () => { + const onOpenCard = vi.fn(); + const card = { + key: "demo-skill", + skillId: "skill-1", + folderId: null, + catalogRef: null, + name: "Demo Skill", + slug: "demo-skill", + author: "Paperclip", + version: null, + tagline: null, + description: null, + categories: [], + iconUrl: null, + color: null, + starCount: 0, + agentCount: 0, + forkCount: 0, + installed: true, + required: false, + forkedFrom: false, + updatedAt: 0, + }; + const node = await renderDiscoveryGrid({ + cards: [card], + totalCount: 1, + onOpenCard, + folderResult: { kind: "skill", folders: [], allCount: 1, unfiledCount: 1 }, + onMoveCard: vi.fn(), + onCreateFolderAndMoveCard: vi.fn(), + }); + const actionsButton = node.querySelector('[aria-label="More actions for Demo Skill"]'); + + await act(async () => { + actionsButton?.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + }); + + expect(onOpenCard).not.toHaveBeenCalled(); + }); }); describe("skillStudioNewRoute", () => { diff --git a/ui/src/pages/CompanySkills.tsx b/ui/src/pages/CompanySkills.tsx index c738b13670f..69c24a3cea7 100644 --- a/ui/src/pages/CompanySkills.tsx +++ b/ui/src/pages/CompanySkills.tsx @@ -779,6 +779,7 @@ function SkillCard({
onOpen(card)} onKeyDown={(event) => { + if (event.target !== event.currentTarget) return; if (event.key === "Enter" || event.key === " ") { event.preventDefault(); onOpen(card);