Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions apps/web/src/components/ChatView.browser.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { createMemoryHistory } from "@tanstack/react-router";
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
import {
scopeProjectRef,
scopedThreadKey,
scopeThreadRef,
} from "@t3tools/client-runtime/environment";
import {
EnvironmentId,
IssueTrackerKind,
Expand Down Expand Up @@ -243,10 +247,12 @@ it("opens a linked Linear issue from an inactive thread's sidebar badge", async
// AppRoot brings its own router.
router: false,
});
const badge = page.getByRole("button", {
const badge = page.getByRole("link", {
name: `Issue ${issue.displayKey}: ${issue.title}, Open`,
});
await expect.element(badge).toBeVisible();
expect(badge.element()).toHaveAttribute("href", issue.url);
expect(badge.element()).toHaveAttribute("target", "_blank");
expect(badge.element().querySelector("span")).toHaveClass(/text-emerald-600/);
expect(badge.element()).toHaveTextContent("123");
expect(badge.element()).not.toHaveTextContent("#");
Expand All @@ -263,6 +269,36 @@ it("opens a linked Linear issue from an inactive thread's sidebar badge", async
await vi.waitFor(() =>
expect(groupedBadge.element().querySelector("span")).toHaveClass(/text-emerald-600/),
);
// Modified clicks on the single-issue badge fall through to the anchor so the browser opens it
// instead of navigating or opening the in-app panel.
for (const modifier of [{ metaKey: true }, { ctrlKey: true }] as const) {
let sawUnpreventedClick = false;
// Register on the React root after mount so this runs after React's delegated click handler
// even when the handler calls stopPropagation(), preventing Chromium from opening a real tab.
const preventExternalNavigation = (event: MouseEvent) => {
if (event.target !== badge.element()) return;
sawUnpreventedClick = !event.defaultPrevented;
event.preventDefault();
};
_app.container.addEventListener("click", preventExternalNavigation);
try {
const modifiedClick = new MouseEvent("click", {
bubbles: true,
cancelable: true,
...modifier,
});
await act(() => badge.element().dispatchEvent(modifiedClick));
} finally {
_app.container.removeEventListener("click", preventExternalNavigation);
}
expect(sawUnpreventedClick).toBe(true);
expect(router.history.location.pathname).toBe(`/${ENVIRONMENT_ID}/${first.id}`);
expect(
useRightPanelStore.getState().byThreadKey[
scopedThreadKey(scopeThreadRef(ENVIRONMENT_ID, linked.id))
],
).toBeUndefined();
}
await userEvent.hover(badge);
const issueName = `Issue ${issue.displayKey}: ${liveTitle}`;
const previewLink = page.getByRole("link", { name: issueName });
Expand Down
18 changes: 18 additions & 0 deletions apps/web/src/components/sidebar/SidebarThreadRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1181,14 +1181,32 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
: gt("{count, plural, one {{count} linked issue} other {{count} linked issues}}", {
count: issueCount,
});
const opensIssueList = issueCount > 1;
const issueBadge = firstIssue ? (
<ThreadLinkBadge
key={opensIssueList ? "list" : "link"}
control={
<InlineButton
render={
opensIssueList ? undefined : (
<a href={firstIssue.url} target="_blank" rel="noopener noreferrer" />
)
}
aria-label={issueLabel}
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.stopPropagation();
if (
!opensIssueList &&
(event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey ||
event.button === 1)
) {
return;
}
event.preventDefault();
openLinkedItems();
}}
/>
Expand Down
Loading