Use "coerceIn" util function

This commit is contained in:
schroda
2024-12-29 23:00:12 +01:00
parent 530ae1578f
commit 8eae025d8f
3 changed files with 9 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ import Slider from '@mui/material/Slider';
import DialogContentText from '@mui/material/DialogContentText';
import InfoIcon from '@mui/icons-material/Info';
import { SxProps, Theme } from '@mui/material/styles';
import { coerceIn } from '@/lib/HelperFunctions.ts';
type BaseProps = {
settingTitle: string;
@@ -170,10 +171,8 @@ export const NumberSetting = ({
type="number"
onChange={(e) => {
const newValue = Number(e.target.value);
const newValueMinLimit = Math.min(newValue, maxValue ?? newValue);
const newValueMaxLimit = Math.max(newValueMinLimit, minValue ?? newValueMinLimit);
updateValue(newValueMaxLimit, false);
const newValueCoerced = coerceIn(newValue, minValue ?? newValue, maxValue ?? newValue);
updateValue(newValueCoerced, false);
}}
slotProps={{
input: {