Files
claude[bot] aaa1b8c0df fix(ui): fail copyToClipboard when the Clipboard API is unavailable (#50641)
<!-- ccr-slack-attribution -->
_Requested by **Pam Chia** · [Slack
thread](https://supabase.slack.com/archives/C076KTY11DF/p1789979683276099?thread_ts=1789953317.522459&cid=C076KTY11DF)_

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix.

## What is the current behavior?

**Before:** `copyToClipboard` writes text with
`navigator.clipboard?.writeText(text)`. When `navigator.clipboard` is
undefined — an insecure context, such as self-hosted Studio served over
plain http or Studio reached over a LAN IP, where `ClipboardItem` is
also undefined so the Safari branch above is skipped — the optional
chaining makes the whole expression resolve to `undefined`. Nothing
throws, so the `catch` never runs and the success callback on the next
line runs anyway. The caller is told the copy succeeded: the UI shows
its "Copied!" confirmation state and the copy-tracking telemetry event
fires as a successful copy, even though nothing reached the clipboard.
That contradicts the documented contract of those events, which are
defined as firing only when the clipboard write succeeded.

## What is the new behavior?

**After:** the missing-clipboard case fails instead of silently
succeeding. The callback does not run, no copy event fires, and the
error toast that the function already shows on failure (`Unable to copy
to clipboard`) is what the user sees. Every working path behaves exactly
as before, including the Safari `ClipboardItem` branch, which is
untouched.

## Additional context

How: throw when `navigator.clipboard` is missing, inside the `try` block
that already exists, so the case lands in the existing `catch` and its
error toast rather than falling through to the success path. The
now-redundant optional chaining on the write is dropped. One case was
added to the existing shared clipboard util tests asserting that the
callback does not fire and the error toast shows when the Clipboard API
is unavailable; it fails on `master` and passes with this change.

Linear:
[GROWTH-1261](https://linear.app/supabase/issue/GROWTH-1261/clipboard-copy-helper-reports-success-when-the-clipboard-api-is)

---
🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01QdJB22CngN3tpc7Kfdpram

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 19:54:37 +08:00
..
2026-09-16 00:00:27 +03:00

packages/ui

Supabase's shared React component library. Built on Radix UI primitives and shadcn/ui, styled with Tailwind CSS, and used across all Supabase apps.

Usage

Import from the 'ui' package alias:

import { Badge, Button, Input } from 'ui'

Some of the components have the _Shadcn_ suffix. These components should be preferred, they're in a process of replacing the other ones.

Utilities

// deep object merge (used for themes)
import { clipboard, cn, mergeDeep } from 'ui' // Tailwind class merging (shadcn-ui/cn)

// copy-to-clipboard helper

Styling conventions

  • Tailwind only — no inline styles or CSS modules.
  • Prefer shadcn semantic pairs (bg-card text-card-foreground, bg-muted text-muted-foreground, bg-tertiary text-tertiary-foreground) over hardcoded colors. Legacy utilities such as text-foreground-light and border-default are compatibility aliases only.
  • Control surface roles (bg-field, bg-control-raised, border-control-hover; CSS --control aliases raised) live in build/css/source/semantic.css. Prefer those over inventing fills. Legacy bg-control is still the accent wash alias.
  • Themes set the core --hue (or the split --surface-hue / --primary-hue), --chroma, --surface, --foreground-lightness, and --contrast inputs, plus their --muted-foreground-level and --tertiary-foreground-level hierarchy. Semantic colors are derived from them in OKLCH; --contrast: 1 is the baseline and the supported adjustment range is 0.75 to 1.25.
  • The workspace root owns the actual tailwind.config.js. The file in this package is a stub for IntelliSense only.