Skip to content

Make the calibration-map geography filter data-driven (fixes blank UK map)#69

Open
juaristi22 wants to merge 1 commit into
PolicyEngine:mainfrom
juaristi22:fix/uk-map-geo-level-filter
Open

Make the calibration-map geography filter data-driven (fixes blank UK map)#69
juaristi22 wants to merge 1 commit into
PolicyEngine:mainfrom
juaristi22:fix/uk-map-geo-level-filter

Conversation

@juaristi22

Copy link
Copy Markdown

Problem

The release-summary page's calibration-map "Geography" filter hardcodes US levels (National / State / Congressional district). Every UK target currently parses to level: "", so on the UK dataset selecting any option filters the treemap to zero tiles — a blank map. The selected level also persisted across country/release switches, so US → "State" → toggle UK left a stale filter applied.

Fix

  • The target-treemap API now returns levels: string[], computed from the unfiltered rows (so a level-filtered request still reports the release's full level list).
  • The overview builds the Geography options from that list (friendly labels for national / state / congressional_district / region, title-cased fallback), and hides the select entirely when the release has no levels (UK today).
  • A selected level that doesn't exist in the current release resets to "All geographies", fixing the stale-filter bug on country/release switches.

Testing

  • bun test: 35 pass, 0 fail (includes a new test covering levels on unfiltered, filtered, and UK-shaped rows).
  • tsc --noEmit: clean.
  • Verified in a headless browser against the live US API (data-driven options, State filtering, US→UK→US stale-filter reset) and with a UK-shaped stubbed response (levels: [] hides the select, map still renders).

Part of a series fixing UK-side dashboard bugs; UK targets gaining real levels (national/region) is a separate PR.

🤖 Generated with Claude Code

The release-summary Geography filter hardcoded US levels (National /
State / Congressional district). UK target rows parse to no level, so
selecting any option filtered the treemap to zero tiles — a blank map.

The target-treemap payload now carries a levels field computed from the
unfiltered rows, so a level-filtered request still reports the full
list. The view builds its options from that list (labelled per level,
title-cased fallback) and hides the select entirely when the release
has no levels, as UK releases do today.

Also fixes the stale-filter bug: the selected level is reset when the
country changes and whenever the response says the level doesn't exist
in the release, instead of silently filtering the map to nothing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant