mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem - proposal to lift scroll bar ui accross the apps - fix shared `ScrollBar` in `ui` showing only a thin `bg-border` thumb with no track, so the scroll position is hard to see ## Solution - replaces the native scrollbars in the docs left nav and in the guide right column with the shared scroll area - replaces the native scrollbar in the docs search v2 results with the shared scroll area, and keeps the animated list height and the bottom fade - changes the command menu list to the shared scroll area, with the bar 2px from the edge so it does not touch the hover highlight - changes the studio connect sheet body and its framework combobox to the shared scroll area, so long code lines still scroll inside their own code blocks | state | preview | | -------|------| | before | <img width="473" height="260" alt="image" src="https://github.com/user-attachments/assets/ef22e643-b92a-4a23-9c77-6b10851e1445" /> | | after | <img width="473" height="260" alt="image" src="https://github.com/user-attachments/assets/46fe95e9-0574-4eef-afbd-20d591baa859" /> | <!-- ## 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 [/design-system/docs/components/scroll-area](https://design-system-git-antlio-feat-ui-scrollbar-track-supabase.vercel.app/design-system/docs/components/scroll-area), scroll the vertical and horizontal demos, and make sure that the thumb moves on a visible track and gets lighter on hover 2. open [/docs/guides/database/postgres/row-level-security](https://docs-git-antlio-feat-ui-scrollbar-track-supabase.vercel.app/docs/guides/database/postgres/row-level-security), scroll the left nav and the right column, and make sure that each shows the new scrollbar 3. resize the page to mobile width, open the menu, and make sure that it scrolls above the footer 4. make sure that the results scroll with the trackpad and with the arrow keys, and that the bottom fade shows 5. open [/dashboard](https://studio-git-antlio-feat-ui-scrollbar-track-supabase.vercel.app/dashboard), press `⌘K`, scroll the command menu, and make sure that the thumb does not touch the hover highlight of an item 6. open [/dashboard/project/_?showConnect=true](https://studio-git-antlio-feat-ui-scrollbar-track-supabase.vercel.app/dashboard/project/_?showConnect=true), scroll the connect sheet, and make sure that long code lines scroll inside their code blocks and do not widen the sheet ## 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)
123 lines
3.8 KiB
TypeScript
123 lines
3.8 KiB
TypeScript
import { screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { mockAnimationsApi } from 'jsdom-testing-mocks'
|
|
import { describe, expect, test, vi } from 'vitest'
|
|
|
|
import type { ResolvedField } from './Connect.types'
|
|
import { ConnectConfigSection } from './ConnectConfigSection'
|
|
import { customRender } from '@/tests/lib/custom-render'
|
|
|
|
mockAnimationsApi()
|
|
|
|
const frameworkField: ResolvedField = {
|
|
id: 'framework',
|
|
type: 'combobox',
|
|
label: 'Framework',
|
|
combobox: {
|
|
placeholder: 'Select framework',
|
|
searchPlaceholder: 'Search frameworks...',
|
|
emptyMessage: 'No frameworks found',
|
|
},
|
|
resolvedOptions: [],
|
|
}
|
|
|
|
const frameworkOptions = [
|
|
{ value: 'nextjs', label: 'Next.js' },
|
|
{ value: 'react', label: 'React' },
|
|
{ value: 'react-native', label: 'React Native' },
|
|
]
|
|
|
|
const manyFrameworkOptions = Array.from({ length: 20 }, (_, index) => ({
|
|
value: `framework-${index}`,
|
|
label: `Framework ${index}`,
|
|
}))
|
|
|
|
describe('ConnectConfigSection', () => {
|
|
test('filters frameworks, selects the matching option, and clears the search on close', async () => {
|
|
const user = userEvent.setup()
|
|
const onFieldChange = vi.fn()
|
|
|
|
customRender(
|
|
<ConnectConfigSection
|
|
activeFields={[frameworkField]}
|
|
state={{ framework: 'nextjs' }}
|
|
onFieldChange={onFieldChange}
|
|
getFieldOptions={() => frameworkOptions}
|
|
/>
|
|
)
|
|
|
|
await user.click(screen.getByRole('combobox'))
|
|
await user.type(screen.getByPlaceholderText('Search frameworks...'), 'native')
|
|
|
|
expect(screen.getByRole('option', { name: 'React Native' })).toBeInTheDocument()
|
|
expect(screen.queryByRole('option', { name: 'Next.js' })).not.toBeInTheDocument()
|
|
|
|
await user.click(screen.getByRole('option', { name: 'React Native' }))
|
|
|
|
expect(onFieldChange).toHaveBeenCalledWith('framework', 'react-native')
|
|
|
|
await user.click(screen.getByRole('combobox'))
|
|
expect(screen.getByPlaceholderText('Search frameworks...')).toHaveValue('')
|
|
})
|
|
|
|
test('matches frameworks by key without announcing the empty state', async () => {
|
|
const user = userEvent.setup()
|
|
|
|
customRender(
|
|
<ConnectConfigSection
|
|
activeFields={[frameworkField]}
|
|
state={{ framework: 'nextjs' }}
|
|
onFieldChange={vi.fn()}
|
|
getFieldOptions={() => frameworkOptions}
|
|
/>
|
|
)
|
|
|
|
await user.click(screen.getByRole('combobox'))
|
|
await user.type(screen.getByPlaceholderText('Search frameworks...'), 'nextjs')
|
|
|
|
expect(screen.getByRole('option', { name: 'Next.js' })).toBeInTheDocument()
|
|
expect(screen.getByRole('status')).toBeEmptyDOMElement()
|
|
})
|
|
|
|
test('announces when no frameworks match the search', async () => {
|
|
const user = userEvent.setup()
|
|
|
|
customRender(
|
|
<ConnectConfigSection
|
|
activeFields={[frameworkField]}
|
|
state={{ framework: 'nextjs' }}
|
|
onFieldChange={vi.fn()}
|
|
getFieldOptions={() => frameworkOptions}
|
|
/>
|
|
)
|
|
|
|
await user.click(screen.getByRole('combobox'))
|
|
await user.type(screen.getByPlaceholderText('Search frameworks...'), 'missing')
|
|
|
|
expect(screen.getByRole('status')).toHaveTextContent('No frameworks found')
|
|
})
|
|
|
|
test('uses a bounded scroll area for long framework lists', async () => {
|
|
const user = userEvent.setup()
|
|
|
|
customRender(
|
|
<ConnectConfigSection
|
|
activeFields={[frameworkField]}
|
|
state={{ framework: 'framework-0' }}
|
|
onFieldChange={vi.fn()}
|
|
getFieldOptions={() => manyFrameworkOptions}
|
|
/>
|
|
)
|
|
|
|
const combobox = document.getElementById('connect-framework')
|
|
expect(combobox).toBeTruthy()
|
|
|
|
await user.click(combobox!)
|
|
|
|
const listbox = screen.getByRole('listbox')
|
|
expect(combobox!.getAttribute('aria-controls')).toBe(listbox.id)
|
|
|
|
expect(screen.getAllByRole('option')).toHaveLength(20)
|
|
})
|
|
})
|