fix: minor bugs for mapped for funders demo#306
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes several minor bugs for the "funders demo" in a mapping application. The changes include refactoring a display value formatting function, fixing UI conditional rendering logic, and improving user-facing labels.
Changes:
- Created a centralized
getDisplayValueutility function inutils/stats.tsto format values for display (numbers, percentages, etc.) - Fixed conditional rendering of the style section in
VisualisationPanelto hide when secondary column is selected (bivariate mode) - Modified fill color logic to add null-safety check for feature-state values
- Updated labels in
ColumnRoleFieldsto clarify optional fields
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/app/map/[id]/utils/stats.ts |
New utility function for formatting display values with percentage detection |
src/app/map/[id]/components/inspector/BoundaryDataPanel.tsx |
Updated to use new getDisplayValue function with column definitions |
src/app/map/[id]/components/controls/VisualisationPanel/VisualisationPanel.tsx |
Added conditional rendering to hide style section in bivariate mode |
src/app/map/[id]/components/Choropleth/useChoroplethColors.ts |
Modified cleanup logic in feature state effect |
src/app/map/[id]/components/Choropleth/index.tsx |
Minor formatting change (blank line) |
src/app/map/[id]/components/BoundaryHoverInfo/utils.ts |
Removed getDisplayValue function (moved to stats.ts) |
src/app/map/[id]/components/BoundaryHoverInfo/AreasList.tsx |
Updated to use new getDisplayValue from stats.ts |
src/app/map/[id]/colors.ts |
Added null-safety wrapper for fill color expression |
src/app/(private)/data-sources/[id]/components/ColumnRoleFields.tsx |
Improved label clarity for optional fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!areaStats || !map) { | ||
| prevAreaStatValues.current = new Map(); | ||
| return; |
There was a problem hiding this comment.
The removal of the cleanup function from this useEffect could lead to stale state issues. The previous implementation had a cleanup function that reset areaCodesToClean.current and prevAreaStatValues.current when the effect was torn down (component unmount or dependency change).
Now, line 45 only clears prevAreaStatValues.current when !areaStats || !map, but areaCodesToClean.current is never reset. This means:
- If the component unmounts and remounts,
areaCodesToClean.currentwill still have old area codes from the previous mount - When dependencies change but the ref persists, old area codes might not be cleaned up properly
Consider either:
- Restoring the cleanup function to reset both refs
- Also resetting
areaCodesToClean.currenton line 45 along withprevAreaStatValues.current
a84b17e to
21c9bc9
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.