mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
feat(desktop): make PR smart chips copy the full URL on text selection
The visible chip label (icon + owner/repo#number) is marked user-select:none while a hidden zero-width span holds the full URL for clipboard copy. Adds an e2e test verifying the DOM structure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
d4043920a4
commit
a3784fc00a
@@ -52,13 +52,16 @@ function createMarkdownComponents(
|
||||
return (
|
||||
<a
|
||||
{...props}
|
||||
className="inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-sm font-medium text-primary no-underline transition-colors hover:bg-primary/20"
|
||||
className="relative inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-sm font-medium text-primary no-underline transition-colors hover:bg-primary/20"
|
||||
href={href}
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<GitPullRequest className="size-3.5" />
|
||||
{owner}/{repo}#{number}
|
||||
<span className="pointer-events-none select-none inline-flex items-center gap-1" aria-hidden="true">
|
||||
<GitPullRequest className="size-3.5" />
|
||||
{owner}/{repo}#{number}
|
||||
</span>
|
||||
<span className="absolute w-0 overflow-hidden whitespace-nowrap">{href}</span>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,32 @@ test("GitHub PR chip links open in new tab", async ({ page }) => {
|
||||
await expect(prChip).toHaveAttribute("rel", "noreferrer");
|
||||
});
|
||||
|
||||
test("selecting a PR chip copies the full URL, not the chip label", async ({
|
||||
page,
|
||||
}) => {
|
||||
const prUrl = "https://github.com/block/goose2/pull/125";
|
||||
|
||||
await page.goto("/");
|
||||
await page.getByTestId("channel-general").click();
|
||||
await expect(page.getByTestId("chat-title")).toHaveText("general");
|
||||
|
||||
const input = page.getByTestId("message-input");
|
||||
await input.fill(prUrl);
|
||||
await page.getByTestId("send-message").click();
|
||||
|
||||
const lastRow = page.getByTestId("message-row").last();
|
||||
const prChip = lastRow.locator("a", { hasText: "block/goose2#125" });
|
||||
await expect(prChip).toBeVisible();
|
||||
|
||||
// The hidden span should contain the full URL for selection/copy
|
||||
const hiddenUrl = prChip.locator("span.overflow-hidden");
|
||||
await expect(hiddenUrl).toHaveText(prUrl);
|
||||
|
||||
// The visible label should not be selectable
|
||||
const visibleLabel = prChip.locator("span.select-none");
|
||||
await expect(visibleLabel).toBeVisible();
|
||||
});
|
||||
|
||||
test("non-PR GitHub links render as regular links", async ({ page }) => {
|
||||
const repoUrl = "https://github.com/block/sprout";
|
||||
const message = `Check out ${repoUrl}`;
|
||||
|
||||
Reference in New Issue
Block a user