Skip to content

Commit

Permalink
[Disaster Dashboard] Fix zoom buttons on disaster specific maps (#2776)
Browse files Browse the repository at this point in the history
Fixes a bug where the (+)/(-) zoom buttons on the individual disaster
maps don't do anything on click. This PR makes the ids of each button
div unique, which fixes the issue.


https://github.com/datacommonsorg/website/assets/4034366/e9cc526f-29a8-4e98-b1e0-34a4a9244aea
  • Loading branch information
juliawu authored Jun 6, 2023
1 parent 7db5876 commit b8b597f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions static/js/components/tiles/disaster_event_map_tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
addPolygonLayer,
drawD3Map,
getProjection,
MapZoomParams,
} from "../../chart/draw_d3_map";
import {
GeoJsonData,
Expand Down Expand Up @@ -110,7 +111,10 @@ export const DisasterEventMapTile = memo(function DisasterEventMapTile(
_.isNull(props.disasterEventData);
const shouldShowMap =
!isInitialLoading && !_.isEmpty(baseMapGeoJson.features);

const zoomParams = {
zoomInButtonId: `${ZOOM_IN_BUTTON_ID}-${props.id}`,
zoomOutButtonId: `${ZOOM_OUT_BUTTON_ID}-${props.id}`,
};
useEffect(() => {
if (_.isNull(props.disasterEventData)) {
return;
Expand Down Expand Up @@ -143,7 +147,8 @@ export const DisasterEventMapTile = memo(function DisasterEventMapTile(
baseMapGeoJson,
props.disasterEventData,
polygonGeoJson,
pathGeoJson
pathGeoJson,
zoomParams
);
}
}, [
Expand Down Expand Up @@ -187,13 +192,13 @@ export const DisasterEventMapTile = memo(function DisasterEventMapTile(
{shouldShowMap && (
<div className={`${CSS_SELECTOR_PREFIX}-zoom-button-section`}>
<div
id={ZOOM_IN_BUTTON_ID}
id={zoomParams.zoomInButtonId}
className={`${CSS_SELECTOR_PREFIX}-zoom-button`}
>
<i className="material-icons">add</i>
</div>
<div
id={ZOOM_OUT_BUTTON_ID}
id={zoomParams.zoomOutButtonId}
className={`${CSS_SELECTOR_PREFIX}-zoom-button`}
>
<i className="material-icons">remove</i>
Expand Down Expand Up @@ -343,14 +348,11 @@ export const DisasterEventMapTile = memo(function DisasterEventMapTile(
geoJsonData: GeoJsonData,
disasterEventData: Record<string, DisasterEventPointData>,
polygonGeoJson: GeoJsonData,
pathGeoJson: GeoJsonData
pathGeoJson: GeoJsonData,
zoomParams: MapZoomParams
): void {
const width = svgContainerRef.current.offsetWidth;
const height = svgHeight;
const zoomParams = {
zoomInButtonId: ZOOM_IN_BUTTON_ID,
zoomOutButtonId: ZOOM_OUT_BUTTON_ID,
};
const isUsaPlace = isChildPlaceOf(
props.place.dcid,
USA_PLACE_DCID,
Expand Down

0 comments on commit b8b597f

Please sign in to comment.