diff --git a/apps/game/src/components/online/invite-link-card.tsx b/apps/game/src/components/online/invite-link-card.tsx index cf70180..cd3c58c 100644 --- a/apps/game/src/components/online/invite-link-card.tsx +++ b/apps/game/src/components/online/invite-link-card.tsx @@ -1,6 +1,6 @@ import { cn } from "@repo/nativ/utils" import { useMutation } from "@tanstack/react-query" -import { useId, useState } from "react" +import { useEffect, useId, useRef, useState } from "react" import { useTranslation } from "react-i18next" import { CheckIcon, @@ -55,6 +55,10 @@ export function InviteLinkCard({ const [status, setStatus] = useState("idle") const [justCopied, setJustCopied] = useState(false) const [canShare] = useState(canShareLinks) + const copiedTimer = useRef(undefined) + + //the check outlives the tap by two seconds, and the sheet may not + useEffect(() => () => window.clearTimeout(copiedTimer.current), []) const url = create.data?.url const isMade = Boolean(url) @@ -75,7 +79,11 @@ export function InviteLinkCard({ setStatus(next) if (next !== "copied") return setJustCopied(true) - window.setTimeout(() => setJustCopied(false), COPIED_MS) + window.clearTimeout(copiedTimer.current) + copiedTimer.current = window.setTimeout( + () => setJustCopied(false), + COPIED_MS, + ) } async function handleShare() { diff --git a/apps/game/src/components/online/recent-opponents.tsx b/apps/game/src/components/online/recent-opponents.tsx index fe699ff..0146d0f 100644 --- a/apps/game/src/components/online/recent-opponents.tsx +++ b/apps/game/src/components/online/recent-opponents.tsx @@ -126,7 +126,10 @@ function OpponentChip({ className="peer absolute inset-0 z-10 size-full cursor-[inherit] appearance-none rounded-xl opacity-0" /> + {/* The face is for the eye: its initial read first would put a stray + letter in front of the name in the chip's accessible name. */}