Skip to content

Commit 37d7902

Browse files
authored
fix(dashboard): prevent dashboard from getting unmounted when on the logs page (#2298)
1 parent 1e563b1 commit 37d7902

File tree

2 files changed

+204
-193
lines changed

2 files changed

+204
-193
lines changed

apps/sim/app/workspace/[workspaceId]/logs/components/dashboard/dashboard.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,19 @@ export default function Dashboard({
289289

290290
const executions = metricsQuery.data?.workflows ?? []
291291
const aggregateSegments = metricsQuery.data?.aggregateSegments ?? []
292-
const loading = metricsQuery.isLoading
293292
const error = metricsQuery.error?.message ?? null
294293

294+
/**
295+
* Loading state logic using TanStack Query best practices:
296+
* - isPending: true when there's no cached data (initial load only)
297+
* - isFetching: true when any fetch is in progress
298+
* - isPlaceholderData: true when showing stale data from keepPreviousData
299+
*
300+
* We only show skeleton on initial load (isPending + no data).
301+
* For subsequent fetches, keepPreviousData shows stale content while fetching.
302+
*/
303+
const showSkeleton = metricsQuery.isPending && !metricsQuery.data
304+
295305
// Check if any filters are actually applied
296306
const hasActiveFilters = useMemo(
297307
() =>
@@ -747,7 +757,7 @@ export default function Dashboard({
747757
}
748758
}, [refreshTrigger])
749759

750-
if (loading) {
760+
if (showSkeleton) {
751761
return <DashboardSkeleton />
752762
}
753763

0 commit comments

Comments
 (0)