Skip to content

Fix empty layers spinning forever in Multi Map legend#352

Open
ethanbienstock wants to merge 3 commits into
raft-tech:mainfrom
ethanbienstock:bug-fix/lazy-loading-on-empty-layers
Open

Fix empty layers spinning forever in Multi Map legend#352
ethanbienstock wants to merge 3 commits into
raft-tech:mainfrom
ethanbienstock:bug-fix/lazy-loading-on-empty-layers

Conversation

@ethanbienstock
Copy link
Copy Markdown
Collaborator

Summary

  • Differentiate between loading and empty layer states in the Multi Map legend so that layers with no data stop showing an infinite spinner
  • Add a gray "Visible but Empty" label below the group title for empty layers, aligned with the group header
  • Gray out the checkbox accent color for empty layer entries
  • Add 6 tests covering the new empty layer behavior

Closes #350

Focus Score

9/10 — All changes are tightly scoped to one bug: empty layers causing an infinite spinner in the Multi Map legend. The only files touched are the legend component, its test file, the layer processing logic in Multi.tsx, and the shared type definition. The formatting commit is a minor tangent but affects the same file.

Detailed Summary of Each File Changed

superset-frontend/plugins/geoset-map-chart/src/GeoSetMultiMap/Multi.tsx

  • Removed the early return null when getGeoSetMapLayer returns null (empty data)
  • Changed layerStatesGenerator call to a ternary that returns [] when newLayer is falsy
  • Changed the !newLayerStates.length branch from return null to setting legendEntry.empty = true, so the entry still reaches the legend

superset-frontend/plugins/geoset-map-chart/src/components/MultiLegend.tsx

  • Added NoDataLabel styled component (gray, 11px, aligned with group title via margin-left: -20px)
  • Renders "Visible but Empty" text when legendEntry.empty is true
  • Added $empty transient prop to VisibilityCheckbox and IndeterminateCheckbox to apply accent-color: gray styling
  • Computed allEmpty at the group level for the group header checkbox

superset-frontend/plugins/geoset-map-chart/src/types.ts

  • Added empty?: boolean field to the LegendEntry type

superset-frontend/plugins/geoset-map-chart/test/components/MultiLegend.test.tsx

  • Added 6 tests in a new empty layer state describe block:
    1. Empty entry shows checkbox + "Visible but Empty" label (not spinner)
    2. Non-empty entry does not show the label
    3. Group header shows checkbox when all entries are empty
    4. Group header checkbox present when mix of empty/non-empty
    5. Loading takes precedence over empty (spinners shown)
    6. Transition from loading to empty replaces spinner with label

Test Plan

  • Automated: Run npx jest --config jest.config.js plugins/geoset-map-chart/test/components/MultiLegend.test.tsx — all 30 tests should pass
  • Manual: Open the Hurricane dashboard with year filter set to 2026 (no data). Verify the legend shows "Visible but Empty" in gray text instead of an infinite spinner
  • Manual: Switch the year filter to a year with data (e.g. 2024). Verify the spinner transitions to the normal legend content
  • Manual: With multiple layer groups, verify the group-level checkbox turns gray when all entries in the group are empty

Ethan Bienstock and others added 3 commits March 23, 2026 13:31
When a layer loads but has no data (e.g., filtered to a year with no
storms), loadSingleLayer now returns an entry with empty: true on the
legend instead of null. This lets the legend replace the loading spinner
with a gray checkbox, distinguishing "loaded but empty" from "still
loading". Applies to all layer types (eager, autozoom, and lazy).

Closes raft-tech#350

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show a gray text label aligned with the group title when a layer loads
successfully but returns no data, replacing the previous silent state
that left users staring at a spinner. Add six tests covering the empty
layer state, loading precedence, and the loading-to-empty transition.

Co-Authored-By: Claude Opus 4.6 (1M context) <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.

Lazy loading on an empty layer causes weird behavior

1 participant