-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: minor visualisation panel tweaks, default boundaries to WMC24 when panel opened #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, | ||
|
|
@@ -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( | ||
|
|
@@ -47,6 +48,16 @@ export function useChoropleth() { | |
| zoom, | ||
| ]); | ||
|
|
||
| const setBoundariesPanelOpen = useCallback( | ||
| (open: boolean) => { | ||
| if (open && viewConfig.areaSetGroupCode === undefined) { | ||
| updateViewConfig({ areaSetGroupCode: AreaSetGroupCode.WMC24 }); | ||
| } | ||
| _setBoundariesPanelOpen(open); | ||
| }, | ||
| [_setBoundariesPanelOpen, updateViewConfig, viewConfig.areaSetGroupCode], | ||
| ); | ||
|
Comment on lines
51
to
59
|
||
|
|
||
| return { | ||
| boundariesPanelOpen, | ||
| setBoundariesPanelOpen, | ||
|
|
||
There was a problem hiding this comment.
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, butareaSetGroupCodecan be bothnullandundefinedin 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 becomesnull. This means opening the boundaries panel after setting it to "None" won't trigger the default WMC24 assignment. Consider checking for bothnullandundefinedusing a falsy check like!viewConfig.areaSetGroupCodeor explicitly checking for both values.