Skip to content

Commit

Permalink
Merge pull request #1903 from bphan002/1889-de-select-nc-selection-on…
Browse files Browse the repository at this point in the history
…-outside-click

1889 de select nc selection on outside click
  • Loading branch information
bphan002 authored Jan 27, 2025
2 parents 5691699 + ebdeb61 commit 8c43ecc
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -556,29 +556,35 @@ class Map extends React.Component {
} = this.props;

const features = this.getAllFeaturesAtPoint(e.point);
for (let i = 0; i < features.length; i += 1) {
const feature = features[i];
if (feature.layer.id == 'nc-fills') {
this.setState({ address: null });

this.resetAddressSearch(); // Clear address search input
dispatchCloseBoundaries(); // Collapse boundaries section
if (!features.length) {
this.reset()
} else {
for (let i = 0; i < features.length; i += 1) {
const feature = features[i];
if (feature.layer.id == 'nc-fills') {
this.setState({ address: null });

const selectedCouncilId = Number(feature.properties.NC_ID);
const newSelectedCouncil = councils.find(
({ councilId }) => councilId === selectedCouncilId
);
const newSelected = isEmpty(newSelectedCouncil)
? null
: [newSelectedCouncil];
this.resetAddressSearch(); // Clear address search input
dispatchCloseBoundaries(); // Collapse boundaries section

dispatchUpdateSelectedCouncils(newSelected);
dispatchUpdateUnselectedCouncils(councils);
dispatchUpdateNcId(selectedCouncilId);
const selectedCouncilId = Number(feature.properties.NC_ID);
const newSelectedCouncil = councils.find(
({ councilId }) => councilId === selectedCouncilId
);
const newSelected = isEmpty(newSelectedCouncil)
? null
: [newSelectedCouncil];

return this.ncLayer.selectRegion(feature.id);
} else {
return null;
dispatchUpdateSelectedCouncils(newSelected);
dispatchUpdateUnselectedCouncils(councils);
dispatchUpdateNcId(selectedCouncilId);

return this.ncLayer.selectRegion(feature.id);

} else {
return null;
}
}
}
};
Expand Down

0 comments on commit 8c43ecc

Please sign in to comment.