From 40a178a6369e45a3dcdb510783e9bbcd23ab7148 Mon Sep 17 00:00:00 2001 From: Owen Moogk Date: Thu, 24 Oct 2024 11:32:03 +0200 Subject: [PATCH 1/2] Fix number input NaN issue --- .../@mantine/core/src/components/NumberInput/NumberInput.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx b/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx index 5b046a19ef5..7dbe999419c 100644 --- a/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx +++ b/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx @@ -476,8 +476,8 @@ export const NumberInput = factory((_props, ref) => { const parsedValue = parseFloat(replaced); setValue( Number.isNaN(parsedValue) || parsedValue > Number.MAX_SAFE_INTEGER - ? replaced - : parsedValue + ? clamp(replaced, min, max) + : clamp(parsedValue, min, max) ); } }} From 0122d7687dff4002c6edab12a9c9066e266a6f51 Mon Sep 17 00:00:00 2001 From: Owen Moogk Date: Tue, 5 Nov 2024 13:35:01 +0100 Subject: [PATCH 2/2] Fix issue with clamping the replaced value --- .../@mantine/core/src/components/NumberInput/NumberInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx b/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx index 7dbe999419c..88cef2654a5 100644 --- a/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx +++ b/packages/@mantine/core/src/components/NumberInput/NumberInput.tsx @@ -476,7 +476,7 @@ export const NumberInput = factory((_props, ref) => { const parsedValue = parseFloat(replaced); setValue( Number.isNaN(parsedValue) || parsedValue > Number.MAX_SAFE_INTEGER - ? clamp(replaced, min, max) + ? replaced : clamp(parsedValue, min, max) ); }