Skip to content
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

1889 de select nc selection on outside click #1903

Merged
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