1
0
Fork 0

[react] fix: Fix weird slider behaviour when entering default value (#246)

Fixes #212

Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/246
Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org>
Co-authored-by: Jonathan Haas <haasjona@gmail.com>
Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
Jonathan Haas 2025-04-13 09:00:08 +00:00 committed by Joost De Cock
parent a9f5ba5392
commit 915e52b7d4

View file

@ -233,7 +233,7 @@ export const MenuMmInput = (props) => {
/** A {@see SliderInput} to handle percentage values */ /** A {@see SliderInput} to handle percentage values */
export const MenuPctInput = ({ current, changed, updateHandler, config, ...rest }) => { export const MenuPctInput = ({ current, changed, updateHandler, config, ...rest }) => {
const factor = 100 const factor = 100
let pctCurrent = changed ? menuRoundPct(current, factor) : current let pctCurrent = menuRoundPct(changed ? current : config.dflt, factor)
const pctUpdateHandler = useCallback( const pctUpdateHandler = useCallback(
(path, newVal) => (path, newVal) =>
updateHandler(path, newVal === undefined ? undefined : menuRoundPct(newVal, 1 / factor)), updateHandler(path, newVal === undefined ? undefined : menuRoundPct(newVal, 1 / factor)),