Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/app/map/[id]/components/BoundaryHoverInfo/AreasList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function AreasList({
className="border-none"
style={{ tableLayout: "auto", width: "auto" }}
>
{multipleAreas && (
{multipleAreas && primaryLabel && (
<TableHeader className="pointer-events-auto">
<TableRow className="border-none hover:bg-transparent uppercase font-mono">
<TableHead className="py-2 px-3 text-left h-8" />
Expand Down Expand Up @@ -91,23 +91,25 @@ export function AreasList({
<span className="truncate">{area.name}</span>
</div>
</TableCell>
{area.primaryDisplayValue && !multipleAreas && (
{primaryLabel && !multipleAreas && (
<TableCell className="px-2 py-2 h-8">
<div className="w-px bg-neutral-200 h-full" />
</TableCell>
)}
<TableCell className="py-2 px-3 whitespace-normal h-8">
{multipleAreas ? (
area.primaryDisplayValue || "-"
) : (
<div className="flex flex-row justify-center items-center text-right">
<span className="mr-3 text-muted-foreground uppercase font-mono text-xs">
{primaryLabel}:
</span>
<span>{area.primaryDisplayValue}</span>
</div>
)}
</TableCell>
{primaryLabel && (
<TableCell className="py-2 px-3 whitespace-normal h-8">
{multipleAreas ? (
area.primaryDisplayValue || "-"
) : (
<div className="flex flex-row justify-center items-center text-right">
<span className="mr-3 text-muted-foreground uppercase font-mono text-xs">
{primaryLabel}:
</span>
<span>{area.primaryDisplayValue}</span>
</div>
)}
</TableCell>
)}
{secondaryLabel && (
<TableCell className="py-2 px-3 whitespace-normal h-8">
{multipleAreas ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import SteppedColorEditor from "./SteppedColorEditor";
import type { AreaSetGroupCode } from "@/server/models/AreaSet";
import type { DataSource } from "@/server/models/DataSource";

const SELECT_TO_BUTTON_CLASSES =
"bg-background hover:bg-accent hover:text-accent-foreground hover:border-border font-medium cursor-pointer";

function IncludeColumnsModal({
dataSource,
selectedColumns,
Expand Down Expand Up @@ -258,7 +261,7 @@ export default function VisualisationPanel({
}
>
<SelectTrigger
className="w-full min-w-0"
className={cn("w-full min-w-0", SELECT_TO_BUTTON_CLASSES)}
id="choropleth-boundary-select"
>
<SelectValue placeholder="Choose boundaries..." />
Expand Down Expand Up @@ -298,7 +301,7 @@ export default function VisualisationPanel({
}
>
<SelectTrigger
className="w-full min-w-0"
className={cn("w-full min-w-0", SELECT_TO_BUTTON_CLASSES)}
id="choropleth-calculation-select"
>
<SelectValue placeholder="Choose calculation..." />
Expand Down Expand Up @@ -425,7 +428,7 @@ export default function VisualisationPanel({
}
>
<SelectTrigger
className="w-full min-w-0"
className={cn("w-full min-w-0", SELECT_TO_BUTTON_CLASSES)}
id="choropleth-aggregation-select"
>
<SelectValue placeholder="Choose an aggregation..." />
Expand Down
17 changes: 14 additions & 3 deletions src/app/map/[id]/hooks/useChoropleth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";

import { useAtom } from "jotai";
import { useMemo } from "react";
import { useCallback, useMemo } from "react";
import { AreaSetGroupCode } from "@/server/models/AreaSet";
import { GeocodingType } from "@/server/models/DataSource";
import {
boundariesPanelOpenAtom,
Expand All @@ -15,10 +16,10 @@ import { useMapViews } from "./useMapViews";

export function useChoropleth() {
const zoom = useZoom();
const { viewConfig } = useMapViews();
const { viewConfig, updateViewConfig } = useMapViews();
const choroplethDataSource = useChoroplethDataSource();

const [boundariesPanelOpen, setBoundariesPanelOpen] = useAtom(
const [boundariesPanelOpen, _setBoundariesPanelOpen] = useAtom(
boundariesPanelOpenAtom,
);
const [selectedBivariateBucket, setSelectedBivariateBucket] = useAtom(
Expand Down Expand Up @@ -47,6 +48,16 @@ export function useChoropleth() {
zoom,
]);

const setBoundariesPanelOpen = useCallback(
(open: boolean) => {
if (open && viewConfig.areaSetGroupCode === undefined) {
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for undefined, but areaSetGroupCode can be both null and undefined in the codebase. When a user explicitly sets boundaries to "None" (via useBoundariesControl.tsx line 66, MapStyleSelector.tsx line 183, or VisualisationPanel.tsx line 259), the value becomes null. This means opening the boundaries panel after setting it to "None" won't trigger the default WMC24 assignment. Consider checking for both null and undefined using a falsy check like !viewConfig.areaSetGroupCode or explicitly checking for both values.

Suggested change
if (open && viewConfig.areaSetGroupCode === undefined) {
if (open && viewConfig.areaSetGroupCode == null) {

Copilot uses AI. Check for mistakes.
updateViewConfig({ areaSetGroupCode: AreaSetGroupCode.WMC24 });
}
_setBoundariesPanelOpen(open);
},
[_setBoundariesPanelOpen, updateViewConfig, viewConfig.areaSetGroupCode],
);
Comment on lines 51 to 59
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setBoundariesPanelOpen(true) now updates areaSetGroupCode whenever it’s falsy. Since the map view default (and an explicit user choice via “No locality”) is null, opening the panel will always force WMC24 and makes it impossible to persist a null boundary selection across opens. Consider distinguishing between “unset” and “explicitly none” (e.g., only default when areaSetGroupCode is undefined, or gate this behavior behind an explicit user action / map type).

Copilot uses AI. Check for mistakes.

return {
boundariesPanelOpen,
setBoundariesPanelOpen,
Expand Down
2 changes: 1 addition & 1 deletion src/app/map/[id]/utils/mapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const createNewViewConfig = (): MapViewConfig => {
areaDataSourceId: "",
areaDataColumn: "",
areaDataNullIsZero: true,
areaSetGroupCode: null,
areaSetGroupCode: undefined,
mapStyleName: MapStyleName.Light,
showLabels: true,
showBoundaryOutline: false,
Expand Down