Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion assets/js/dashboard/stats/reports/index-breakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ export function IndexBreakdown({
return (
<LazyLoader onVisible={() => setVisible(true)}>
<IndexBreakdownRenderer<QueryResultRow>
// The key forces remount on every query change so that fade-in
// animation could trigger, even when results are instantly
// available from TanStack cache.
key={JSON.stringify(statsReportQueryKey)}
{...apiState}
rows={apiState.data?.results?.slice(0, MAX_ITEMS) ?? []}
getDimensionValue={(row) => row.dimensions[0]}
Expand Down Expand Up @@ -453,6 +457,7 @@ export function IndexBreakdownRenderer<TRow>({
if (!columns || isPending || (isPlaceholderData && !isRealtimeSilentUpdate)) {
return (
<div
key="loading"
className="w-full flex flex-col justify-center"
style={{ minHeight: `${MIN_HEIGHT}px` }}
>
Expand All @@ -466,6 +471,7 @@ export function IndexBreakdownRenderer<TRow>({
if (rows.length === 0) {
return (
<div
key="empty"
className="w-full h-full flex flex-col justify-center"
style={{ minHeight: `${MIN_HEIGHT}px` }}
>
Expand All @@ -477,7 +483,10 @@ export function IndexBreakdownRenderer<TRow>({
}

return (
<div className="h-full flex flex-col opacity-100 transition-opacity duration-300 starting:opacity-0">
<div
key="data"
className="h-full flex flex-col opacity-100 transition-opacity duration-300 starting:opacity-0"
>
<div
style={{ height: ROW_HEIGHT }}
className="pt-3 w-full text-xs font-medium text-gray-500 dark:text-gray-400 flex items-center"
Expand Down
6 changes: 6 additions & 0 deletions assets/js/dashboard/stats/sources/search-terms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { numberShortFormatter } from '../../util/number-formatter'
import RocketIcon from '../modals/rocket-icon'
import LazyLoader from '../../components/lazy-loader'
import { PlausibleSite, useSiteContext } from '../../site-context'
import { useDashboardStateContext } from '../../dashboard-state-context'
import {
SearchTermsErrorCode,
SearchTermsErrorPayload,
Expand Down Expand Up @@ -72,6 +73,7 @@ export function SearchTerms({
onDataReady: (data: SearchTermsSuccessResponse) => void
}) {
const site = useSiteContext()
const { dashboardState } = useDashboardStateContext()

const [visible, setVisible] = React.useState(false)

Expand Down Expand Up @@ -140,6 +142,10 @@ export function SearchTerms({
return (
<LazyLoader onVisible={() => setVisible(true)}>
<IndexBreakdownRenderer<SearchTermsResultItem>
// The key forces remount on every query change so that fade-in
// animation could trigger, even when results are instantly
// available from TanStack cache.
key={JSON.stringify(dashboardState)}
{...apiState}
rows={apiState.data?.results ?? []}
getDimensionValue={(row) => row.name}
Expand Down
Loading