fix(compare): stale-basket fetch blanking comparisons; rail caption #52

Merged
tudor merged 3 commits from fix/compare-final-review-mustfix into main 2026-07-17 06:28:28 +00:00
Showing only changes of commit 80176cac4d - Show all commits
+6 -5
View File
@@ -133,15 +133,16 @@ export function ComparisonView({
// Guard against out-of-order responses: while the basket hydrates from
// localStorage it can transiently hold a DIFFERENT school set than the
// URL, firing a fetch for schools the user is no longer comparing. That
// stale response must not replace data for the current set — replacing
// it blanked every section until a hard refresh. We (a) drop responses
// from superseded effect runs and (b) merge rather than replace, so data
// for the current schools always survives.
// stale response must not replace data for the current set — it blanked
// every section until a hard refresh. Cleanup marks the run cancelled
// when urnKey moves on, so only the current selection's response is
// applied (replacing the map keeps it bounded and guarantees a re-added
// school is refetched fresh rather than served a lingering old entry).
let cancelled = false;
fetchComparison(urnKey, { cache: 'no-store' })
.then((data) => {
if (cancelled) return;
setComparisonData((prev) => ({ ...(prev ?? {}), ...data.comparison }));
setComparisonData(data.comparison);
setNationalAverages(data.national_averages);
setBenchmarks(data.benchmarks);
})