Skip to content

Commit f2ec298

Browse files
committed
Fix Charts preview history synchronization
1 parent 8cf0df4 commit f2ec298

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/components/charts/ChartsBuilderPage.client.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,15 +808,12 @@ export function ChartsBuilderPage() {
808808
if (!trustedUrl) return
809809
const currentHistory = previewHistoryRef.current
810810
const currentUrl = currentHistory.entries[currentHistory.index] ?? '/'
811-
812-
setPreviewHistory((current) => {
813-
const next = updateExamplePreviewHistory(current, {
814-
kind: message.navigationKind,
815-
url: trustedUrl,
816-
})
817-
previewHistoryRef.current = next
818-
return next
811+
const nextHistory = updateExamplePreviewHistory(currentHistory, {
812+
kind: message.navigationKind,
813+
url: trustedUrl,
819814
})
815+
previewHistoryRef.current = nextHistory
816+
setPreviewHistory(nextHistory)
820817
setPreviewNavigationError('')
821818
if (message.navigationKind === 'load' || currentUrl !== trustedUrl) {
822819
setPreviewAnnotationTarget(undefined)

src/components/charts/ChartsCatalogResult.client.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,12 @@ export function ChartsCatalogResult({
168168
if (!trustedUrl) return
169169
const currentHistory = previewHistoryRef.current
170170
const currentUrl = currentHistory.entries[currentHistory.index] ?? '/'
171-
172-
setPreviewHistory((current) => {
173-
const next = updateExamplePreviewHistory(current, {
174-
kind: message.navigationKind,
175-
url: trustedUrl,
176-
})
177-
previewHistoryRef.current = next
178-
return next
171+
const nextHistory = updateExamplePreviewHistory(currentHistory, {
172+
kind: message.navigationKind,
173+
url: trustedUrl,
179174
})
175+
previewHistoryRef.current = nextHistory
176+
setPreviewHistory(nextHistory)
180177
setPreviewNavigationError('')
181178
if (message.navigationKind === 'load' || currentUrl !== trustedUrl) {
182179
setPreviewAnnotationTarget(undefined)

0 commit comments

Comments
 (0)