From 352b2c510f03c7c47c5b3d09d350d704f4caa8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=C5=BDaba?= Date: Sun, 30 Jul 2023 23:17:53 +0200 Subject: [PATCH] handle-accounting-sign-on-tab-key-focus --- src/currencyInput.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/currencyInput.ts b/src/currencyInput.ts index e53eef2..ae7d76d 100644 --- a/src/currencyInput.ts +++ b/src/currencyInput.ts @@ -158,6 +158,7 @@ export class CurrencyInput { } if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) { formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix) + formattedValue = formattedValue.length ? `${formattedValue})` : formattedValue } if (this.minValue >= 0) { formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix) @@ -217,6 +218,9 @@ export class CurrencyInput { } } } + if (selectionStart === 1 && caretPositionFromLeft === 0 && this.formattedValue.endsWith(')')) { + caretPositionFromLeft = 1 + } return this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden ? newValueLength - caretPositionFromLeft : Math.max(newValueLength - Math.max(caretPositionFromLeft, suffix.length), prefix.length)