Skip to content

Commit 7ccd921

Browse files
committed
fix(webapp): hide copy controls after pointer exit
1 parent f4afd7e commit 7ccd921

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

apps/webapp/app/components/code/TSQLResultsTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ function CopyableCell({
847847
// the same SimpleTooltip, so it is never unmounted/remounted on hover (which would drop
848848
// keyboard focus). The tooltip is left uncontrolled so Radix opens it only when the pointer or
849849
// keyboard focus is actually on the button, not whenever the pointer is anywhere in this
850-
// virtualized grid's cell.
850+
// virtualized grid's cell. `focus-visible:` (not `focus:`) ensures keyboard focus reveals the
851+
// button without leaving it visible after a mouse click moves outside the cell.
851852
const copyButton = (
852853
<button
853854
type="button"
@@ -858,7 +859,7 @@ function CopyableCell({
858859
copy();
859860
}}
860861
className={cn(
861-
"absolute right-1 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded border border-border-bright bg-background-hover transition-opacity focus:opacity-100",
862+
"absolute right-1 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded border border-border-bright bg-background-hover transition-opacity focus-visible:pointer-events-auto focus-visible:opacity-100",
862863
isHovered ? "opacity-100" : "pointer-events-none opacity-0",
863864
copied
864865
? "text-green-500"

apps/webapp/app/components/primitives/CopyableText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function CopyableText({
7777
</span>
7878
<span
7979
className={cn(
80-
"absolute top-0 z-10 flex size-6 font-sans transition-opacity focus-within:opacity-100",
80+
"absolute top-0 z-10 flex size-6 font-sans transition-opacity has-focus-visible:pointer-events-auto has-focus-visible:opacity-100",
8181
// Truncated values reserve a right gutter, so the button sits inside it
8282
truncate ? "right-0" : "-right-6",
8383
isHovered ? "opacity-100" : "pointer-events-none opacity-0"

apps/webapp/app/components/primitives/Table.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ export const CopyableTableCell = forwardRef<HTMLTableCellElement, CopyableTableC
482482
// the same SimpleTooltip, so it is never unmounted/remounted on hover (which would drop
483483
// keyboard focus). The tooltip is left uncontrolled so Radix opens it only when the pointer
484484
// or keyboard focus is actually on the button, not whenever the pointer is anywhere in the cell.
485+
// `focus-visible:` reveals keyboard focus without leaving the button visible after a mouse click
486+
// moves outside the cell.
485487
const copyButton = (
486488
<button
487489
type="button"
@@ -492,7 +494,7 @@ export const CopyableTableCell = forwardRef<HTMLTableCellElement, CopyableTableC
492494
copy();
493495
}}
494496
className={cn(
495-
"absolute -right-2 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded border border-border-bright bg-background-hover transition-opacity focus:opacity-100",
497+
"absolute -right-2 top-1/2 z-10 flex size-6 -translate-y-1/2 items-center justify-center rounded border border-border-bright bg-background-hover transition-opacity focus-visible:pointer-events-auto focus-visible:opacity-100",
496498
isHovered ? "opacity-100" : "pointer-events-none opacity-0",
497499
copied
498500
? "text-green-500"

apps/webapp/app/components/runs/v3/RunTag.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function CopyButton({ textToCopy, isHovered }: { textToCopy: string; isHovered:
122122
onClick={copy}
123123
onMouseDown={(e) => e.stopPropagation()}
124124
className={cn(
125-
"absolute -right-6 top-0 z-10 flex size-6 items-center justify-center rounded-r-sm border-y border-r border-border-bright bg-background-hover transition-opacity focus:opacity-100",
125+
"absolute -right-6 top-0 z-10 flex size-6 items-center justify-center rounded-r-sm border-y border-r border-border-bright bg-background-hover transition-opacity focus-visible:pointer-events-auto focus-visible:opacity-100",
126126
isHovered ? "opacity-100" : "pointer-events-none opacity-0",
127127
copied
128128
? "text-green-500"
@@ -171,7 +171,7 @@ function DeleteButton({
171171
onClick={handleDelete}
172172
onMouseDown={(e) => e.stopPropagation()}
173173
className={cn(
174-
"absolute -right-6 top-0 z-10 flex size-6 items-center justify-center rounded-r-sm border-y border-r border-border-bright bg-background-hover transition-opacity focus:opacity-100",
174+
"absolute -right-6 top-0 z-10 flex size-6 items-center justify-center rounded-r-sm border-y border-r border-border-bright bg-background-hover transition-opacity focus-visible:pointer-events-auto focus-visible:opacity-100",
175175
isHovered ? "opacity-100" : "pointer-events-none opacity-0",
176176
"text-text-dimmed hover:border-border-bright hover:bg-background-raised hover:text-rose-400"
177177
)}

0 commit comments

Comments
 (0)