diff --git a/src/mantine-core/src/components/NumberInput/NumberInput.test.tsx b/src/mantine-core/src/components/NumberInput/NumberInput.test.tsx index 03fa374a1d0..419d7383d78 100644 --- a/src/mantine-core/src/components/NumberInput/NumberInput.test.tsx +++ b/src/mantine-core/src/components/NumberInput/NumberInput.test.tsx @@ -73,7 +73,7 @@ describe('@mantine/core/NumberInput', () => { const spy = jest.fn(); render(); await enterText('5'); - expect(spy).toHaveBeenLastCalledWith(5); + expect(spy).toHaveBeenLastCalledWith('5'); await enterText('{backspace}'); expect(spy).toHaveBeenLastCalledWith(''); expectValue(''); @@ -85,15 +85,15 @@ describe('@mantine/core/NumberInput', () => { focusInput(); await enterText('3'); - expect(spy).toHaveBeenLastCalledWith(3); + expect(spy).toHaveBeenLastCalledWith('3'); expect(spy).toHaveBeenCalledTimes(1); await enterText('2'); - expect(spy).toHaveBeenLastCalledWith(32); + expect(spy).toHaveBeenLastCalledWith('32'); expect(spy).toHaveBeenCalledTimes(2); await enterText('a'); - expect(spy).toHaveBeenLastCalledWith(32); + expect(spy).toHaveBeenLastCalledWith('32'); expect(spy).toHaveBeenCalledTimes(2); }); diff --git a/src/mantine-core/src/components/NumberInput/NumberInput.tsx b/src/mantine-core/src/components/NumberInput/NumberInput.tsx index 1e2e3572c96..73a85f2c747 100644 --- a/src/mantine-core/src/components/NumberInput/NumberInput.tsx +++ b/src/mantine-core/src/components/NumberInput/NumberInput.tsx @@ -227,7 +227,11 @@ export const NumberInput = factory((_props, ref) => { }); const handleValueChange: OnValueChange = (payload, event) => { - setValue(isValidNumber(payload.floatValue) ? payload.floatValue : payload.value); + setValue( + typeof _value === 'number' && isValidNumber(payload.floatValue) + ? payload.floatValue + : payload.value + ); onValueChange?.(payload, event); };