Repository navigation
Description
Problem
Switching between the Domains and URLs tabs on the Citations page (/dashboard/citations) feels sluggish, especially for brands with many cited domains/URLs.
Root cause (it is NOT a data fetch)
Tab switching does not trigger any re-fetch. Both tabs are fed from a single getCitationsOverview() call whose result (data.rows + data.urlRows) is already in memory; the tabs only toggle which table is shown.
The lag is a re-mount + synchronous render cost:
- The tabs use Base-UI's
Tabs.Panel(web/src/components/ui/tabs.tsx), and the wrapper does not passkeepMounted. Base-UI unmounts the inactive panel by default, so every switch destroys the old table and mounts the other one from scratch. - The tables are uncapped: in
web/src/lib/actions/citations.ts(~lines 300–336)rowsOut/urlRowsOutcontain one row per distinct domain / URL with no limit. For a brand with many prompts × platforms, the URLs table can be hundreds of rows, so re-rendering it on each switch is expensive.
Why a skeleton is NOT the fix
A skeleton only helps while data is being awaited. Here the data is already loaded and tab switching does no async work — a skeleton would just flash an empty placeholder before the table renders, making the transition feel worse, not better. Please do not add a per-tab skeleton for this.
Proposed fix
keepMounted— passkeepMountedto theTabsContent(Base-UITabs.Panel) for the Domains/URLs panels so both mount once and switching becomes a pure CSS visibility toggle (instant). The data is already fetched, so this is a one-time render cost, not per-switch.- Memoize the tables — wrap
DomainsTable/UrlsTableinReact.memoso an unrelated parent re-render doesn't re-render the whole table.
Optional follow-up (separate, larger)
For brands where a tab reaches hundreds/thousands of rows, row virtualization (windowing) is the scalable fix. Out of scope for this issue — track separately if it proves necessary after 1+2.
Files to touch
web/src/components/ui/tabs.tsx— confirmkeepMountedreachesTabs.Panelvia{...props}(it should), or expose itweb/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx— passkeepMountedon the twoTabsContent; wrapDomainsTable/UrlsTableinReact.memo
How to test
- Open
/dashboard/citationsfor a brand with a large number of cited URLs. - Switch Domains ↔ URLs repeatedly — the switch is instant, with no visible render delay.
- Confirm in DevTools/Network that no server action fires on tab switch (it already doesn't).
- Filtering still re-fetches and re-renders both tables correctly (no regression).
Activity