Skip to content

Commit

Permalink
Merge pull request #41 from concord-consortium/186866293-map-button-fix
Browse files Browse the repository at this point in the history
Adds an codap listener for closing map so we can update the plugin state
  • Loading branch information
eireland authored Jan 30, 2024
2 parents 3720609 + f22bc03 commit 8486bfd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import { initializePlugin } from "@concord-consortium/codap-plugin-api";
import { ClientNotification, addComponentListener, initializePlugin } from "@concord-consortium/codap-plugin-api";
import { LocationPicker } from "./location-picker";
import { DateRange } from "./date-range/date-range";
import { AttributesSelector } from "./attribute-selector";
Expand Down Expand Up @@ -57,7 +57,17 @@ export const App = () => {
addNotificationHandler("notify",
`dataContextChangeNotice[${StationDSName}]`, async (req: any) => {
stationSelectionHandler(req);
});
});
const createMapListener = (listenerRes: ClientNotification) => {
const { values } = listenerRes;
if (values.operation === "delete" && values.type === "DG.MapView" && values.name === "US Weather Stations") {
setState((draft) => {
draft.zoomMap = false;
draft.isMapOpen = false;
});
}
};
addComponentListener(createMapListener);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit 8486bfd

Please sign in to comment.