From 051e499d28129b97bb089fe8457d7fbb61e365b6 Mon Sep 17 00:00:00 2001 From: Bennett Date: Sun, 6 Aug 2023 15:09:40 +0200 Subject: [PATCH] Add support for decimal numbers --- src/shared/components/speedSetting.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/shared/components/speedSetting.tsx b/src/shared/components/speedSetting.tsx index 5ea2494..3d54426 100644 --- a/src/shared/components/speedSetting.tsx +++ b/src/shared/components/speedSetting.tsx @@ -29,6 +29,7 @@ const SpeedSetting = ({ const value = config.current[name] as number const isCustomValue = config.current[`${name}_is_custom` as IsCustomKeys] const [isOpen, setIsOpen] = React.useState(false) + const [tempValue, setTempValue] = React.useState(null) let selector if (isCustomValue) { @@ -37,9 +38,15 @@ const SpeedSetting = ({
{ - config.current[name] = parseInt(evt.target.value) + // Handle incomplete numbers (e.g. "12,") + if (!/[0-9]$/.test(evt.target.value)) { + setTempValue(evt.target.value) + } + + config.current[name] = parseFloat(evt.target.value) + setTempValue(null) if (config.environment === StateEnvironment.Popup) { window.sa_event(`speed_${name}_custom_${evt.target.value}`) @@ -49,7 +56,7 @@ const SpeedSetting = ({ } }} step={0.1} - min={0.0625} + min={0.06} max={16} />