Apply the ordering expressions after the layout, not before

The Bucket and Segment columns never appeared in the column list, and
viewer.save() reported expressions: {}. syncOrderExpressions ran immediately
after viewer.load() — and the saved layout was restored on the next line.
restore() replaces `expressions` wholesale rather than merging, so the
expressions were created and then wiped every single time, before anything
could see them.

Moved to after both restore branches. The effect on [logMeta, versions,
versionId] then keeps them in step, as intended.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-09-17 14:10:55 -04:00
parent 9a748b8178
commit 194134ea5f

View File

@ -755,7 +755,6 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
await viewer.load(tableRef.current) await viewer.load(tableRef.current)
viewer.setAttribute('theme', dark ? 'Pro Dark' : 'Pro Light') viewer.setAttribute('theme', dark ? 'Pro Dark' : 'Pro Light')
if (!hideSplitTotal()) setTimeout(hideSplitTotal, 400) if (!hideSplitTotal()) setTimeout(hideSplitTotal, 400)
await syncOrderExpressions()
// restore last-used layout or build default // restore last-used layout or build default
// Strip cfg.table table is already loaded by reference above; a stale name // Strip cfg.table table is already loaded by reference above; a stale name
@ -793,6 +792,12 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio
} }
// auto-persist viewer state (formatting, columns, etc.) to the last-used cache // auto-persist viewer state (formatting, columns, etc.) to the last-used cache
// After the layout, not before: restoring a saved config replaces
// `expressions` wholesale, so expressions applied earlier were being wiped
// by the very next line and the ordering columns never appeared in the
// column list.
await syncOrderExpressions()
if (viewer._pspUpdate) viewer.removeEventListener('perspective-config-update', viewer._pspUpdate) if (viewer._pspUpdate) viewer.removeEventListener('perspective-config-update', viewer._pspUpdate)
viewer._pspUpdate = async () => { viewer._pspUpdate = async () => {
try { try {