@devries-cameron20 / t3code Mirror · read-only / commits / 5f80af6805
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 13:30 UTC

fix(web): restore word selection in inline code (#36936)

Yash Singh committed Nov 14, 2026 at 15:05 UTC 5f80af680520cda45dc9afa1ec7879b77e105883
2 files changed +6 -10
apps/web/src/components/ChatMarkdown.browser.test.tsx
+5 -3
@@ -626,13 +626,15 @@ describe("ChatMarkdown headings", () => {
626 });
627
628 describe("ChatMarkdown inline code selection", () => {
629 - it("selects the whole inline code span on double-click, but only a word in fenced code", async () => {
629 + it("selects only a word on double-click in inline and fenced code", async () => {
630 setup();
631 await using screen = await renderText(
632 "Run `migration-gate --dry-run` first.\n\n```txt\nfenced-block word\n```",
633 );
634 - await userEvent.dblClick(screen.getByText("migration-gate --dry-run"));
635 - expect(window.getSelection()?.toString()).toBe("migration-gate --dry-run");
634 + await userEvent.dblClick(screen.getByText("migration-gate --dry-run"), {
635 + position: { x: 12, y: 8 },
636 + });
637 + expect(window.getSelection()?.toString()).toBe("migration");
638
639 window.getSelection()?.removeAllRanges();
640 const fenced = screen.container.querySelector("pre code")!;
apps/web/src/components/ChatMarkdown.tsx
+1 -7
@@ -78,7 +78,6 @@ import React, {
78 Suspense,
79 type ComponentProps,
80 type ClipboardEvent as ReactClipboardEvent,
81 - type MouseEvent as ReactMouseEvent,
81 use,
82 memo,
83 useEffect,
@@ -1045,11 +1044,6 @@ function markdownHeadingRenderer(level: 1 | 2 | 3 | 4 | 5 | 6) {
1044 };
1045 }
1046
1048 -// Native word selection stops at hyphens and dots, so a double-click takes the whole span.
1049 -function selectInlineCode(event: ReactMouseEvent<HTMLElement>) {
1050 - window.getSelection()?.selectAllChildren(event.currentTarget);
1051 -}
1052 -
1047 const CHAT_MARKDOWN_COMPONENTS = {
1048 h1: markdownHeadingRenderer(1),
1049 h2: markdownHeadingRenderer(2),
@@ -1458,7 +1452,7 @@ const CHAT_MARKDOWN_COMPONENTS = {
1452 );
1453 }
1454 return (
1461 - <code {...props} className={className} onDoubleClick={selectInlineCode}>
1455 + <code {...props} className={className}>
1456 {children}
1457 </code>
1458 );