From 181f3d09ece5acc4db8ab9745e3fb13d16a0b124 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 4 May 2024 15:20:40 +0530 Subject: [PATCH 1/2] Fix #6522: Minus sign after all selection - InputNumber --- components/lib/inputnumber/InputNumber.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index d5224ddb69..8ff856b9a9 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -650,7 +650,7 @@ export const InputNumber = React.memo( } _currency.current.lastIndex = 0; - + return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex }; }; @@ -672,7 +672,8 @@ export const InputNumber = React.memo( if (sign.isMinusSign) { const isNewMinusSign = minusCharIndex === -1; - if (isNewMinusSign && (selectionStart === 0 || selectionStart === currencyCharIndex + 1)) { + // #6522 - Selected negative value can't be overwritten with a minus ('-') symbol + if (selectionStart === 0 || selectionStart === currencyCharIndex + 1) { newValueStr = inputValue; if (isNewMinusSign || selectionEnd !== 0) { From b3089bb62f8d9d68fa1501c9e0016f042d807f44 Mon Sep 17 00:00:00 2001 From: Usman Shaikh Date: Sat, 4 May 2024 19:39:14 +0530 Subject: [PATCH 2/2] Formatted --- components/lib/inputnumber/InputNumber.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index 8ff856b9a9..09b2437413 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -650,7 +650,7 @@ export const InputNumber = React.memo( } _currency.current.lastIndex = 0; - + return { decimalCharIndex, minusCharIndex, suffixCharIndex, currencyCharIndex }; };