Skip to content

Commit eee59bb

Browse files
authored
Merge pull request #1853 from hackforla/1837-Selecting-an-NC-when-another-selected
removed conditional for resetting boundary
2 parents 0e5455a + 19d47b6 commit eee59bb

File tree

1 file changed

+19
-44
lines changed

1 file changed

+19
-44
lines changed

components/Map/Map.jsx

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ const styles = (theme) => ({
100100
});
101101

102102
// Define feature layers
103-
const hoverables = ['nc-fills', 'cc-fills'];
104-
const featureLayers = ['request-circles', ...hoverables];
103+
const featureLayers = ['request-circles','nc-fills'];
105104

106105
class Map extends React.Component {
107106
// Note: 'this.context' is defined using the static contextType property
@@ -474,51 +473,27 @@ class Map extends React.Component {
474473
const features = this.getAllFeaturesAtPoint(e.point);
475474
for (let i = 0; i < features.length; i += 1) {
476475
const feature = features[i];
476+
if (feature.layer.id == "nc-fills") {
477+
this.setState({ address: null });
477478

478-
if (
479-
!isEmpty(this.props.selectedNcId) &&
480-
!isEmpty(feature.properties.NC_ID) &&
481-
this.props.selectedNcId !== feature.properties.NC_ID
482-
) {
483-
// Since click is for another district
484-
485-
// Reset boundaries selection
486-
this.resetBoundaries();
487-
488-
// Collapse boundaries section
489-
dispatchCloseBoundaries();
479+
this.resetAddressSearch(); // Clear address search input
480+
dispatchCloseBoundaries(); // Collapse boundaries section
490481

491-
// Reset Address Search input field
492-
this.resetAddressSearch();
493-
494-
// Reset Map.
495-
this.reset();
496-
497-
return;
498-
}
482+
const selectedCouncilId = Number(feature.properties.NC_ID);
483+
const newSelectedCouncil = councils.find(
484+
({ councilId }) => councilId === selectedCouncilId
485+
);
486+
const newSelected = isEmpty(newSelectedCouncil)
487+
? null
488+
: [newSelectedCouncil];
499489

500-
if (hoverables.includes(feature.layer.id) && !feature.state.selected) {
501-
switch (feature.layer.id) {
502-
case 'nc-fills':
503-
this.setState({ address: null });
504-
this.resetAddressSearch(); // Clear address search input
505-
dispatchCloseBoundaries(); // Collapse boundaries section
506-
const selectedCouncilId = Number(feature.properties.NC_ID);
507-
const newSelectedCouncil = councils.find(
508-
({ councilId }) => councilId === selectedCouncilId
509-
);
510-
const newSelected = isEmpty(newSelectedCouncil)
511-
? null
512-
: [newSelectedCouncil];
513-
dispatchUpdateSelectedCouncils(newSelected);
514-
dispatchUpdateUnselectedCouncils(councils);
515-
dispatchUpdateNcId(selectedCouncilId);
516-
return this.ncLayer.selectRegion(feature.id);
517-
case 'cc-fills':
518-
return this.ccLayer.selectRegion(feature.id);
519-
default:
520-
return null;
521-
}
490+
dispatchUpdateSelectedCouncils(newSelected);
491+
dispatchUpdateUnselectedCouncils(councils);
492+
dispatchUpdateNcId(selectedCouncilId);
493+
494+
return this.ncLayer.selectRegion(feature.id);
495+
} else{
496+
return null;
522497
}
523498
}
524499
};

0 commit comments

Comments
 (0)