Files
anthony lio f05fe34966 feat(ui): scroll area (#54023)
## Problem

- on `/kb/guides/migrate-from-auth0` in safari 27 on macos, the mouse
wheel does not scroll the page and a trackpad does
- radix scroll area bar in the table of contents adds a non-passive
`wheel` listener on `document`
- webkit stops mouse-wheel page scroll when that listener meets
`overscroll-behavior-y: none` on `html`, which kb sets

## Solution

- replaces radix with base ui in the `ui` scroll area parts because base
ui binds its wheel listener to the scrollbar element
- replaces the radix `display: table` workarounds in the studio token
sheets and the connect sheet with a reset of the base ui content
`min-width`
- changes the docs ask ai scroll area to use the `ui` scroll area
- adds an inset focus ring to the scroll area viewport because base ui
makes an overflowing viewport focusable
- adds a `getAnimations` stub to the jsdom test setups because the base
ui viewport calls it
- adds `@base-ui/react` to the pnpm catalog + points the design system
scroll area page at the base ui docs

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. open the preview
[/kb/guides/migrate-from-auth0](https://kb-git-antlio-ui-scroll-area-supabase.vercel.app/kb/guides/migrate-from-auth0)
in safari on macos with a mouse
2. turn the mouse wheel and make sure that the page scrolls and the
table of contents marks the active heading
3. open the preview
[/design-system/docs/components/scroll-area](https://design-system-git-antlio-ui-scroll-area-supabase.vercel.app/design-system/docs/components/scroll-area)
and make sure that each demo shows its bar on hover and scrolls with the
wheel
4. make sure that the horizontal demo scrolls sideways
5. press `tab` until a demo takes focus and make sure that it shows an
inset focus ring
6. open a project in the [studio
preview](https://studio-staging-git-antlio-ui-scroll-area-supabase.vercel.app/dashboard),
click `Connect` and make sure that a long code line scrolls inside its
code block and the sheet body does not scroll sideways
7. open the [docs
preview](https://docs-git-antlio-ui-scroll-area-supabase.vercel.app/docs),
press `cmd+k`, search for `auth` and make sure that the results list
scrolls

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-28 13:25:55 +02:00

39 lines
937 B
TypeScript

/// <reference types="@testing-library/jest-dom" />
import '@testing-library/jest-dom/vitest'
import { cleanup } from '@testing-library/react'
import { afterEach, vi } from 'vitest'
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
})
// Mock ResizeObserver
global.ResizeObserver = vi.fn().mockImplementation(function () {
return {
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}
})
// Mock scrollIntoView
Element.prototype.scrollIntoView = vi.fn()
// base ui scroll area calls getAnimations, which jsdom does not have
Element.prototype.getAnimations ??= () => []
afterEach(() => {
cleanup()
})