Skip to content

Commit f90611b

Browse files
committed
fix: obs unit menu can vanish after selecting a unit
In certain cases, the observation units menu could disappear after selecting a unit. This should fix that by allowing its visible state to change from false to true, but not from true to false.
1 parent d83fa24 commit f90611b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

frontend-v2/src/features/data/MapObservations.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC } from 'react';
1+
import { FC, useState } from 'react';
22
import { Box, Select, FormControl, MenuItem, InputLabel, Table, TableHead, TableRow, TableCell, TableBody, Typography, SelectChangeEvent } from "@mui/material";
33
import { StepperState } from "./LoadDataStepper";
44
import { useSelector } from "react-redux";
@@ -16,6 +16,7 @@ interface IMapObservations {
1616
}
1717

1818
const MapObservations: FC<IMapObservations> = ({state}: IMapObservations) => {
19+
const [unitsAreFixed, setUnitsAreFixed] = useState(true);
1920
const projectId = useSelector(
2021
(state: RootState) => state.main.selectedProject,
2122
);
@@ -135,6 +136,10 @@ const MapObservations: FC<IMapObservations> = ({state}: IMapObservations) => {
135136
? compatibleSymbols?.includes(selectedUnitSymbol)
136137
: true;
137138
});
139+
const unitsShouldBeFixed = observationUnitField && selectedUnitSymbol;
140+
if (unitsAreFixed && !unitsShouldBeFixed) {
141+
setUnitsAreFixed(false);
142+
}
138143
return (
139144
<TableRow>
140145
<TableCell>
@@ -157,7 +162,7 @@ const MapObservations: FC<IMapObservations> = ({state}: IMapObservations) => {
157162
</FormControl>
158163
</TableCell>
159164
<TableCell>
160-
{observationUnitField && selectedUnitSymbol ?
165+
{unitsAreFixed ?
161166
selectedUnitSymbol :
162167
<FormControl fullWidth>
163168
<InputLabel id={`select-unit-${obsId}-label`}>Units</InputLabel>

0 commit comments

Comments
 (0)