Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

Commit 3b25276

Browse files
authored
fix(InputNumber): fix decimal value on spin (#8139)
1 parent 55b6d5f commit 3b25276

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

components/lib/inputnumber/InputNumber.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ export const InputNumber = React.memo(
213213
return null;
214214
};
215215

216+
const addWithPrecision = (base, increment, precision = 10) => {
217+
return Math.round((base + increment) * precision) / precision;
218+
};
219+
216220
const repeat = (event, interval, dir) => {
217221
let i = interval || 500;
218222

@@ -228,7 +232,7 @@ export const InputNumber = React.memo(
228232
if (inputRef.current) {
229233
let step = props.step * dir;
230234
let currentValue = parseValue(inputRef.current.value) || 0;
231-
let newValue = validateValue(currentValue + step);
235+
let newValue = validateValue(addWithPrecision(currentValue, step));
232236

233237
if (props.maxLength && props.maxLength < formatValue(newValue).length) {
234238
return;

0 commit comments

Comments
 (0)