Fix options sliders not sliding

This commit is contained in:
nickofolas
2022-05-09 19:32:32 -05:00
parent b46718d188
commit 8baafe438d
2 changed files with 17 additions and 10 deletions
+11 -4
View File
@@ -1,8 +1,8 @@
import { Slider, Tooltip, Typography, Box } from "@mui/material";
import React from "react";
import React, { useState } from "react";
interface IProps {
value: any;
initialValue: any;
callback: (event: any, newValue: number | number[]) => void;
step: number;
min: number;
@@ -13,14 +13,21 @@ interface IProps {
}
export const OptionsSlider = (props: IProps): React.ReactElement => {
const [value, setValue] = useState(props.initialValue);
const onChange = (_evt: Event, newValue: number | Array<number>): void => {
setValue(newValue);
};
return (
<Box>
<Tooltip title={<Typography>{props.tooltip}</Typography>}>
<Typography>{props.label}</Typography>
</Tooltip>
<Slider
value={props.value}
onChange={props.callback}
value={value}
onChange={onChange}
onChangeCommitted={(evt) => props.callback(evt, value)}
step={props.step}
min={props.min}
max={props.max}