diff --git a/bun.lockb b/bun.lockb index b8f32cf7..e99b2623 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/src/components/Form/Settings/Slider/Slider.jsx b/src/components/Form/Settings/Slider/Slider.jsx index 1b5a7ee3..5697ef15 100644 --- a/src/components/Form/Settings/Slider/Slider.jsx +++ b/src/components/Form/Settings/Slider/Slider.jsx @@ -2,7 +2,7 @@ import variables from 'config/variables'; import { useState, useCallback, memo, useMemo } from 'react'; import { toast } from 'react-toastify'; import ReactSlider from 'react-slider'; -import { MdRefresh } from 'react-icons/md'; +import { MdRefresh, MdEdit } from 'react-icons/md'; import EventBus from 'utils/eventbus'; import clsx from 'clsx'; @@ -66,13 +66,64 @@ const MULTIPLIER_MARKS = { 400: '4x', }; -// Memoized value display component -const ValueDisplay = memo(({ value, display }) => ( - - {value} - {display} - -)); +// Update ValueDisplay component to show edit affordance +const ValueDisplay = memo(({ value, display, onChange }) => { + const [editing, setEditing] = useState(false); + const [inputValue, setInputValue] = useState(value); + + const handleBlur = () => { + setEditing(false); + const numValue = Number(inputValue); + if (!isNaN(numValue)) { + onChange(numValue); + } else { + setInputValue(value); + } + }; + + const handleKeyDown = (e) => { + if (e.key === 'Enter') { + handleBlur(); + } else if (e.key === 'Escape') { + setEditing(false); + setInputValue(value); + } + }; + + return editing ? ( + setInputValue(e.target.value)} + onBlur={handleBlur} + onKeyDown={handleKeyDown} + className="w-20 text-sm bg-neutral-200 dark:bg-white/15 text-neutral-800 dark:text-white + px-3 py-1.5 rounded-md font-medium outline-none focus:ring-2 + focus:ring-neutral-400 dark:focus:ring-white/40" + autoFocus + /> + ) : ( +