From f2ec29856c6f7d3416facd9e7b09d66bb0eeefaf Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 25 Aug 2026 08:07:59 -0600 Subject: [PATCH] Fix Charts preview history synchronization --- src/components/charts/ChartsBuilderPage.client.tsx | 13 +++++-------- .../charts/ChartsCatalogResult.client.tsx | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/components/charts/ChartsBuilderPage.client.tsx b/src/components/charts/ChartsBuilderPage.client.tsx index f3226b12b..f6c630283 100644 --- a/src/components/charts/ChartsBuilderPage.client.tsx +++ b/src/components/charts/ChartsBuilderPage.client.tsx @@ -808,15 +808,12 @@ export function ChartsBuilderPage() { if (!trustedUrl) return const currentHistory = previewHistoryRef.current const currentUrl = currentHistory.entries[currentHistory.index] ?? '/' - - setPreviewHistory((current) => { - const next = updateExamplePreviewHistory(current, { - kind: message.navigationKind, - url: trustedUrl, - }) - previewHistoryRef.current = next - return next + const nextHistory = updateExamplePreviewHistory(currentHistory, { + kind: message.navigationKind, + url: trustedUrl, }) + previewHistoryRef.current = nextHistory + setPreviewHistory(nextHistory) setPreviewNavigationError('') if (message.navigationKind === 'load' || currentUrl !== trustedUrl) { setPreviewAnnotationTarget(undefined) diff --git a/src/components/charts/ChartsCatalogResult.client.tsx b/src/components/charts/ChartsCatalogResult.client.tsx index 103ac0214..122e78889 100644 --- a/src/components/charts/ChartsCatalogResult.client.tsx +++ b/src/components/charts/ChartsCatalogResult.client.tsx @@ -168,15 +168,12 @@ export function ChartsCatalogResult({ if (!trustedUrl) return const currentHistory = previewHistoryRef.current const currentUrl = currentHistory.entries[currentHistory.index] ?? '/' - - setPreviewHistory((current) => { - const next = updateExamplePreviewHistory(current, { - kind: message.navigationKind, - url: trustedUrl, - }) - previewHistoryRef.current = next - return next + const nextHistory = updateExamplePreviewHistory(currentHistory, { + kind: message.navigationKind, + url: trustedUrl, }) + previewHistoryRef.current = nextHistory + setPreviewHistory(nextHistory) setPreviewNavigationError('') if (message.navigationKind === 'load' || currentUrl !== trustedUrl) { setPreviewAnnotationTarget(undefined)