Skip to content

Commit 940f6d7

Browse files
authored
fix: info row value copy (#335)
Safari copies the visually displayed uppercase text when selecting content by default. This change ensures users copy the underlying value instead, preserving the original text.
1 parent 13d25da commit 940f6d7

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

src/features/dashboard/settings/general/team-info.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
'use client'
22

3+
import { ClipboardEvent } from 'react'
34
import { useDashboard } from '@/features/dashboard/context'
45
import { formatDate } from '@/lib/utils/formatting'
56

6-
const InfoRow = ({ label, value }: { label: string; value: string }) => (
7-
<div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
8-
<span className="text-fg-tertiary shrink-0 text-xs leading-[17px] font-normal uppercase">
9-
{label}
10-
</span>
11-
<span className="text-fg-secondary font-mono text-base leading-5 font-semibold tracking-[-0.16px] uppercase [overflow-wrap:anywhere]">
12-
{value}
13-
</span>
14-
</div>
15-
)
7+
const InfoRow = ({ label, value }: { label: string; value: string }) => {
8+
const handleCopy = (e: ClipboardEvent<HTMLSpanElement>) => {
9+
if (!window.getSelection()?.toString()) return
10+
e.preventDefault()
11+
e.clipboardData.setData('text/plain', value)
12+
}
13+
14+
return (
15+
<div className="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
16+
<span className="text-fg-tertiary shrink-0 text-xs leading-[17px] font-normal uppercase">
17+
{label}
18+
</span>
19+
<span
20+
className="text-fg-secondary font-mono text-base leading-5 font-semibold tracking-[-0.16px] uppercase [overflow-wrap:anywhere]"
21+
onCopy={handleCopy}
22+
>
23+
{value}
24+
</span>
25+
</div>
26+
)
27+
}
1628

1729
export const TeamInfo = () => {
1830
const { team } = useDashboard()

0 commit comments

Comments
 (0)