diff --git a/ui/src/components/BlockedInboxView.test.tsx b/ui/src/components/BlockedInboxView.test.tsx index 98e44bf1fff..9bd971fe4ea 100644 --- a/ui/src/components/BlockedInboxView.test.tsx +++ b/ui/src/components/BlockedInboxView.test.tsx @@ -263,7 +263,7 @@ describe("BlockedInboxView", () => { ); await waitFor(() => container.querySelector("a") !== null); - const rowText = container.querySelector("a")?.textContent ?? ""; + const rowText = container.querySelector("a")?.parentElement?.textContent ?? ""; expect(rowText.indexOf("Pending board decision")).toBeGreaterThanOrEqual(0); expect(rowText.indexOf("Needs decision")).toBeGreaterThan(rowText.indexOf("Pending board decision")); expect(rowText.indexOf("Board")).toBeGreaterThan(rowText.indexOf("Needs decision")); diff --git a/ui/src/components/IssueRow.test.tsx b/ui/src/components/IssueRow.test.tsx index 8b60584a194..1e7c81887ca 100644 --- a/ui/src/components/IssueRow.test.tsx +++ b/ui/src/components/IssueRow.test.tsx @@ -6,6 +6,7 @@ import { createRoot } from "react-dom/client"; import type { Issue } from "@paperclipai/shared"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { IssueRow } from "./IssueRow"; +import { StatusIcon } from "./StatusIcon"; vi.mock("@/lib/router", () => ({ Link: ({ @@ -114,6 +115,33 @@ describe("IssueRow", () => { }); }); + it("keeps editable row controls keyboard-accessible and outside the navigation link", () => { + const root = createRoot(container); + + act(() => { + root.render( + undefined} />} + />, + ); + }); + + const link = container.querySelector("[data-inbox-issue-link]"); + const statusButton = container.querySelector( + 'button[aria-label="Change status (current: Todo)"]', + ); + + expect(link).not.toBeNull(); + expect(statusButton).not.toBeNull(); + expect(statusButton?.tabIndex).toBe(0); + expect(link?.contains(statusButton)).toBe(false); + + act(() => { + root.unmount(); + }); + }); + it("suppresses accent hover styling when the row is selected", () => { const root = createRoot(container); const issue = createIssue(); @@ -296,8 +324,7 @@ describe("IssueRow", () => { ); }); - const link = container.querySelector("[data-inbox-issue-link]") as HTMLAnchorElement | null; - const metaRow = Array.from(link?.querySelectorAll("span.flex.items-center.gap-2") ?? []) + const metaRow = Array.from(container.querySelectorAll("span.flex.items-center.gap-2")) .find((element) => element.textContent?.includes("PAP-42")); expect(metaRow).not.toBeUndefined(); diff --git a/ui/src/components/IssueRow.tsx b/ui/src/components/IssueRow.tsx index 97dd912d4dd..edf45747d5a 100644 --- a/ui/src/components/IssueRow.tsx +++ b/ui/src/components/IssueRow.tsx @@ -162,27 +162,36 @@ export function IssueRow({ ) : null; return ( - rememberIssueDetailLocationState(issuePathId, detailState)} +
+ rememberIssueDetailLocationState(issuePathId, detailState)} + className={cn( + "absolute inset-0 rounded-lg no-underline text-inherit focus-visible:z-10 focus-visible:outline-none focus-visible:ring-(length:--rad-3) focus-visible:ring-ring", + !hideDivider && "border-b border-border last:border-b-0", + selected ? "hover:bg-transparent" : "hover:bg-accent/50", + checklistCurrentStep ? "bg-primary/5" : null, + className, + )} + > + Open {identifier}: {issue.title} + {mobileLeading ?? } {productivityReviewIndicator} @@ -316,7 +325,7 @@ export function IssueRow({ {unreadDotButton} ) : null} - +
); } diff --git a/ui/src/components/IssuesList.tsx b/ui/src/components/IssuesList.tsx index 63bdb73d84b..bdc780966a8 100644 --- a/ui/src/components/IssuesList.tsx +++ b/ui/src/components/IssuesList.tsx @@ -1375,7 +1375,7 @@ export function IssuesList({ const row = rootRef.current?.querySelector( `[data-issue-row-id="${escapeAttrValue(navKey.slice("issue:".length))}"]`, ); - const link = row?.querySelector(":scope > [data-inbox-issue-link]"); + const link = row?.querySelector("[data-inbox-issue-link]"); return link instanceof HTMLElement ? link : null; }, []); diff --git a/ui/src/components/PriorityIcon.interaction.test.tsx b/ui/src/components/PriorityIcon.interaction.test.tsx new file mode 100644 index 00000000000..bb2b6f10214 --- /dev/null +++ b/ui/src/components/PriorityIcon.interaction.test.tsx @@ -0,0 +1,58 @@ +// @vitest-environment jsdom + +import { flushSync } from "react-dom"; +import { createRoot } from "react-dom/client"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { PriorityIcon } from "./PriorityIcon"; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true; + +async function act(callback: () => void | Promise) { + let result: void | Promise = undefined; + flushSync(() => { + result = callback(); + }); + await result; +} + +describe("PriorityIcon picker", () => { + let container: HTMLDivElement; + let root: ReturnType | null; + + beforeEach(() => { + container = document.createElement("div"); + document.body.appendChild(container); + root = createRoot(container); + }); + + afterEach(async () => { + await act(async () => root?.unmount()); + container.remove(); + document.body.innerHTML = ""; + }); + + it("opens the real popover and selects a priority", async () => { + const onChange = vi.fn(); + await act(async () => root?.render()); + + const trigger = container.querySelector( + 'button[aria-label="Change priority (current: Medium)"]', + ); + expect(trigger).not.toBeNull(); + + await act(async () => { + trigger?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + }); + + const highOption = [...document.body.querySelectorAll("button")] + .find((button) => button.textContent?.trim() === "High"); + expect(highOption).not.toBeUndefined(); + + await act(async () => { + highOption?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + }); + expect(onChange).toHaveBeenCalledOnce(); + expect(onChange).toHaveBeenCalledWith("high"); + }); +}); diff --git a/ui/src/components/PriorityIcon.test.tsx b/ui/src/components/PriorityIcon.test.tsx new file mode 100644 index 00000000000..dd31dfb7b56 --- /dev/null +++ b/ui/src/components/PriorityIcon.test.tsx @@ -0,0 +1,14 @@ +// @vitest-environment node + +import { renderToStaticMarkup } from "react-dom/server"; +import { describe, expect, it } from "vitest"; +import { PriorityIcon } from "./PriorityIcon"; + +describe("PriorityIcon", () => { + it("uses an accessible native button for the icon-only picker trigger", () => { + const html = renderToStaticMarkup( {}} />); + + expect(html).toContain(' - ) : icon; + ) : ( + + ); return ( diff --git a/ui/src/components/StatusIcon.test.tsx b/ui/src/components/StatusIcon.test.tsx index 2415b7e7d5d..87fc0a8dcde 100644 --- a/ui/src/components/StatusIcon.test.tsx +++ b/ui/src/components/StatusIcon.test.tsx @@ -86,10 +86,13 @@ describe("StatusIcon", () => { expect(html).toContain("Blocked · review stalled on PAP-2279"); }); - it("keeps the onChange picker working with the glyph", () => { + it("uses an accessible native button for the icon-only picker trigger", () => { const html = renderToStaticMarkup( {}} />); expect(html).toContain('viewBox="0 0 24 24"'); + expect(html).toContain(' ) : ( - glyph + ); return ( diff --git a/ui/src/pages/Inbox.test.tsx b/ui/src/pages/Inbox.test.tsx index 659f9fa53b2..48a3deccea9 100644 --- a/ui/src/pages/Inbox.test.tsx +++ b/ui/src/pages/Inbox.test.tsx @@ -528,16 +528,15 @@ describe("Inbox toolbar", () => { const rows = Array.from(container.querySelectorAll("[data-inbox-item]")); const rowFor = (text: string) => rows.find((row) => row.textContent?.includes(text)); - const linkOf = (row: Element) => row.querySelector("a[data-inbox-issue-link]"); const markReadButton = (row: Element) => row.querySelector('button[aria-label="Mark as read"]'); // The empty spacer that reserves the chevron column on every leaf row. // Excludes the tree-guide span (`.self-stretch`), which only renders on // nested rows. const hasLeadingSpacer = (row: Element) => - !!linkOf(row)?.querySelector("span.hidden.w-4.shrink-0.sm\\:block:not(.self-stretch)"); + !!row.querySelector("span.hidden.w-4.shrink-0.sm\\:block:not(.self-stretch)"); // The reserved leading dot slot, present on read AND unread rows. const dotSlot = (row: Element) => - linkOf(row)?.querySelector('[data-testid="issue-row-unread-slot"]') ?? null; + row.querySelector('[data-testid="issue-row-unread-slot"]'); const unreadRow = rowFor("Unread inbox row")!; const readRow = rowFor("Read inbox row")!; diff --git a/ui/src/pages/IssueDetail.test.tsx b/ui/src/pages/IssueDetail.test.tsx index 4aa6b5c3b5a..cc0efb5071f 100644 --- a/ui/src/pages/IssueDetail.test.tsx +++ b/ui/src/pages/IssueDetail.test.tsx @@ -331,13 +331,36 @@ vi.mock("../components/ScrollToBottom", () => ({ })); vi.mock("../components/StatusIcon", () => ({ - StatusIcon: ({ status, blockerAttention }: { status: string; blockerAttention?: Issue["blockerAttention"] }) => ( - {status} - ), + StatusIcon: ({ + status, + blockerAttention, + onChange, + }: { + status: string; + blockerAttention?: Issue["blockerAttention"]; + onChange?: (status: string) => void; + }) => onChange ? ( + + ) : {status}, })); vi.mock("../components/PriorityIcon", () => ({ - PriorityIcon: ({ priority }: { priority: string }) => {priority}, + PriorityIcon: ({ priority, onChange }: { priority: string; onChange?: (priority: string) => void }) => onChange ? ( + + ) : {priority}, })); vi.mock("../components/ApprovalCard", () => ({ @@ -1036,6 +1059,50 @@ describe("IssueDetail", () => { ).toBe(false); }); + it("updates status and priority from the task header controls", async () => { + const issue = createIssue({ status: "todo", priority: "medium" }); + mockIssuesApi.get.mockResolvedValue(issue); + mockIssuesApi.update.mockImplementation(async (_issueId: string, data: Record) => ({ + ...issue, + ...data, + })); + + await act(async () => { + root.render( + + + , + ); + }); + await flushReact(); + await flushReact(); + + const statusButton = container.querySelector( + 'button[aria-label="Change status (current: todo)"]', + ); + const priorityButton = container.querySelector( + 'button[aria-label="Change priority (current: medium)"]', + ); + expect(statusButton).not.toBeNull(); + expect(priorityButton).not.toBeNull(); + + await act(async () => { + statusButton!.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true })); + }); + await waitForAssertion(() => { + expect(mockIssuesApi.update).toHaveBeenCalledWith(issue.identifier, { status: "done" }); + }); + + await act(async () => { + priorityButton!.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true })); + }); + await waitForAssertion(() => { + expect(mockIssuesApi.update).toHaveBeenCalledWith(issue.identifier, { priority: "high" }); + }); + + mockIssuesApi.update.mockReset(); + }); + it("removes an inbox-origin archived issue from cached inbox variants before navigating back", async () => { const issue = createIssue({ id: "issue-1", identifier: "PAP-1", title: "Archive me from detail" }); const otherIssue = createIssue({ id: "issue-2", identifier: "PAP-2", title: "Keep me in inbox" });