Skip to content

Commit

Permalink
fix: fix bug preventing new searches after selecting a feature
Browse files Browse the repository at this point in the history
Closes #745
  • Loading branch information
stdavis committed Aug 29, 2024
1 parent f651f1a commit aca7350
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/ResultsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@ export default function ResultsPanel() {
const [state] = useSearchMachine();
const [expandedTableName, setExpandedTableName] = useState(null);

const { selectedGraphicInfo } = useMap();
const { selectedGraphicInfo, setSelectedGraphicInfo } = useMap();
console.log('selectedGraphicInfo', selectedGraphicInfo);

useEffect(() => {
if (selectedGraphicInfo) {
setExpandedTableName(selectedGraphicInfo.layerId);
}
setExpandedTableName(
selectedGraphicInfo ? selectedGraphicInfo.layerId : null,
);
}, [
selectedGraphicInfo,
state.context.resultLayers,
state.context.searchLayerTableNames,
]);

// clear selected graphic for new searches
useEffect(() => {
if (state.context.resultLayers === null) {
console.log('setting to null');
setSelectedGraphicInfo(null);
}
}, [setSelectedGraphicInfo, state.context.resultLayers]);

const originalHeight = 256;
const [height, setHeight] = useState(originalHeight);

Expand Down

0 comments on commit aca7350

Please sign in to comment.