mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
Studio is on `react@^19.2.6`, and `useEffectEvent` shipped stable in React 19.2 with the same signature as the userland polyfill. This drops the local hook in `apps/studio` and `apps/www` in favor of the built-in. **Removed:** - `apps/studio/hooks/useStaticEffectEvent.ts` - `apps/www/hooks/useStaticEffectEvent.ts` - `.claude/skills/use-static-effect-event/` — skill is obsolete **Changed:** - 26 call sites: dropped the `useStaticEffectEvent` import, added `useEffectEvent` to the existing `react` import, renamed call sites - `.claude/CLAUDE.md`: `apps/studio` row updated React 18 → React 19 - `.claude/skills/vercel-composition-patterns/SKILL.md`: removed stale "Studio uses React 18, skip these patterns" warning ## To test - `pnpm typecheck --filter=studio` — passes locally - `pnpm typecheck --filter=www` — passes locally - `grep -rn "useStaticEffectEvent"` returns nothing outside `node_modules` - Smoke-test areas that use the hook: schema visualizer edges (intersection check), spreadsheet import, sign-in/CLI login flows, side panels with unsaved-changes prompts **Out of scope:** pre-existing Tailwind lint warning on `DefaultEdge.tsx:141` (`outline` + `outline-1` conflict) — unrelated to this migration <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Internal event handling migrated to React’s built-in event hooks across the Studio app; no user-facing changes. * **Documentation** * Clarified React 19 compatibility and noted Studio now targets React 19. * Removed obsolete documentation for a deprecated internal hook. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46415?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
Table Filtering and Sorting Developer notes
Overview
The table filtering and sorting system uses a URL-based state persistence pattern combined with custom hooks that abstract the implementation details from consuming components. This architecture provides several benefits:
- Persistent state: Filters and sorts are stored in URL parameters, enabling bookmarking and sharing
- Separation of concerns: Logic is separated from UI components
- Draft-then-apply pattern: UI components maintain draft state until explicitly applied
Core Hooks
useTableFilter
// Returns: { filters, urlFilters, onApplyFilters }
The useTableFilter hook manages filter state with these responsibilities:
- Retrieves raw filter parameters from URL
- Formats filter parameters into usable Filter[] objects
- Provides a callback to apply new filters
- Persists changes to URL parameters
- Triggers side effects through
saveFiltersAndTriggerSideEffects
Key design aspects:
- No direct snapshot interaction, keeping it focused solely on filter management
- Uses URL parameters as the source of truth
- Forwards filter changes to URL and triggers application-specific side effects
useTableSort
// Returns: { sorts, urlSorts, onApplySorts }
The useTableSort hook manages sort state with these responsibilities:
- Retrieves raw filter parameters from URL
- Formats sort parameters into usable Sort[] objects (needs table name)
- Provides a callback to apply new sorts
- Persists changes to URL parameters
- Triggers side effects through
saveSortsAndTriggerSideEffects
Key design aspects:
- Handles applying table name to sort objects
- Maintains URL parameters as source of truth
- Forwards sort changes to URL and triggers application-specific side effects
Component Implementation
FilterPopoverPrimitive and SortPopoverPrimitive
These components follow a "draft and apply" pattern:
- Local state management: Both components maintain a local state copy of filters/sorts
- Edit operations: Changes like adding, modifying, or deleting are made to the local state
- Apply operations: Only when the user clicks "Apply" are the changes committed via the callback
- Synchronization: Local state is synchronized with props when external changes occur
Data Flow
- URL parameters store the raw filter/sort state
- Hooks read and format these parameters into usable objects
- UI components receive formatted objects and callbacks
- Components maintain draft state for editing
- When "Apply" is clicked, callbacks update URL parameters
- Side effects are triggered via dedicated save hooks
Component Usage
Components using these hooks should follow this pattern:
function TableComponent() {
// Get filter data and callbacks
const { filters, onApplyFilters } = useTableFilter()
// Get sort data and callbacks
const { sorts, onApplySorts } = useTableSort()
return (
<>
<FilterPopoverPrimitive filters={filters} onApplyFilters={onApplyFilters} />
<SortPopoverPrimitive sorts={sorts} onApplySorts={onApplySorts} />
{/* Table rendering with filters and sorts applied */}
</>
)
}
Implementation Notes
- Filter and sort parameters are stored in URL using specific formats
- Conversion utilities (
formatFilterURLParams,formatSortURLParams, etc.) handle translation between URL strings and typed objects - Side effect hooks manage database persistence and related operations