Skip to content

Commit 11774ef

Browse files
Don't skip layer toggles in GeographySizeTable if there's no overlap
1 parent ae4fc90 commit 11774ef

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

packages/client/src/reports/widgets/GeographySizeTable.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ export const GeographySizeTable: ReportWidget<GeographySizeTableSettings> = ({
6262
return geographies
6363
.filter((geography) => !excludeSet.has(geography.id))
6464
.map((geography) => {
65+
const geoKey = String(geography.id);
66+
const geoOverrides = componentSettings?.geographyStableIds;
67+
const hasOverride = geoOverrides && geoKey in geoOverrides;
68+
const ids = geography.stableIds as (string | null)[] | null | undefined;
69+
const defaultStableId = ids?.[0] ?? undefined;
70+
const resolvedLayerStableId = hasOverride
71+
? geoOverrides[geoKey] ?? undefined
72+
: defaultStableId;
73+
const stableId = enableLayerToggles
74+
? resolvedLayerStableId
75+
: undefined;
76+
6577
const sketchMetrics = metrics.filter(
6678
(m) =>
6779
subjectIsFragment(m.subject) &&
@@ -73,7 +85,7 @@ export const GeographySizeTable: ReportWidget<GeographySizeTableSettings> = ({
7385
geographyName: geography.name,
7486
areaSqKm: 0,
7587
fractionOfTotal: 0,
76-
stableId: undefined,
88+
stableId,
7789
};
7890
}
7991

@@ -93,21 +105,12 @@ export const GeographySizeTable: ReportWidget<GeographySizeTableSettings> = ({
93105
const fractionOfTotal =
94106
geographyArea > 0 ? areaSqKm / geographyArea : 0;
95107

96-
const geoKey = String(geography.id);
97-
const geoOverrides = componentSettings?.geographyStableIds;
98-
const hasOverride = geoOverrides && geoKey in geoOverrides;
99-
const ids = geography.stableIds as (string | null)[] | null | undefined;
100-
const defaultStableId = ids?.[0] ?? undefined;
101-
const stableId = hasOverride
102-
? geoOverrides[geoKey] ?? undefined
103-
: defaultStableId;
104-
105108
return {
106109
geographyId: geography.id,
107110
geographyName: geography.name,
108111
areaSqKm,
109112
fractionOfTotal,
110-
stableId: enableLayerToggles ? stableId : undefined,
113+
stableId,
111114
};
112115
});
113116
}, [

0 commit comments

Comments
 (0)