Apparently a `MenuItem` with a value of `undefined` is possible but
doesn't actually fire a change event. Strange. Use the string `"null"`
instead.
This commit is contained in:
Scott Lamb
2023-02-13 11:05:27 -08:00
parent 64d161d0a7
commit 015dfef9c9
2 changed files with 6 additions and 4 deletions

View File

@@ -214,17 +214,17 @@ interface MonoviewProps {
/** A single pane of a Multiview, including its camera chooser. */
const Monoview = (props: MonoviewProps) => {
const handleChange = (event: SelectChangeEvent<number | null>) => {
const handleChange = (event: SelectChangeEvent<string>) => {
const {
target: { value },
} = event;
props.onSelect(typeof value === "string" ? parseInt(value) : value);
props.onSelect(value === "null" ? null : parseInt(value));
};
const chooser = (
<Select
value={props.cameraIndex == null ? undefined : props.cameraIndex}
value={props.cameraIndex === null ? "null" : props.cameraIndex.toString()}
onChange={handleChange}
displayEmpty
size="small"
@@ -236,7 +236,7 @@ const Monoview = (props: MonoviewProps) => {
},
}}
>
<MenuItem value={undefined}>(none)</MenuItem>
<MenuItem value="null">(none)</MenuItem>
{props.cameras.map((e, i) => (
<MenuItem key={i} value={i}>
{e.shortName}