mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
Fix floating point math issue in scrub (#1562)
## Description Fix of the bug reported in https://discord.com/channels/955905230107738152/1102991527254446182: 1. Set value of any input that you can scrub to 1.3 2. Scrub to decrease it by 1 to 0.3 3. The value gets set 0.30000000000000004
This commit is contained in:
1 parent
d16a340c5c
commit
bcdfc9f83d
1 file changed
+2
-1
@@ -57,7 +57,8 @@ const getValueDefault = (
|
||||
maxValue = Number.MAX_SAFE_INTEGER,
|
||||
}: NumericScrubOptions
|
||||
) => {
|
||||
const value = state.value + movement;
|
||||
// toFixed is needed to fix `1.3 - 1 = 0.30000000000000004`
|
||||
const value = Number((state.value + movement).toFixed(2));
|
||||
if (value < minValue) {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user