From 0122836e029bc0c67c6573d5b114841cb12aafc2 Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Tue, 8 Oct 2024 20:03:59 +0900 Subject: [PATCH 1/5] fix: allow removal of decimal places --- packages/primevue/src/inputnumber/InputNumber.vue | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/primevue/src/inputnumber/InputNumber.vue b/packages/primevue/src/inputnumber/InputNumber.vue index 513c5a63e..6565d252e 100755 --- a/packages/primevue/src/inputnumber/InputNumber.vue +++ b/packages/primevue/src/inputnumber/InputNumber.vue @@ -424,7 +424,7 @@ export default { if (selectionStart === selectionEnd) { const deleteChar = inputValue.charAt(selectionStart - 1); - const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue); + const { decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue); if (this.isNumeralChar(deleteChar)) { const decimalLength = this.getDecimalLength(inputValue); @@ -440,10 +440,6 @@ export default { } else { newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart); } - } else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) { - const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0'; - - newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart); } else if (decimalCharIndexWithoutPrefix === 1) { newValueStr = inputValue.slice(0, selectionStart - 1) + '0' + inputValue.slice(selectionStart); newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : ''; @@ -771,7 +767,6 @@ export default { newValue = this.parseValue(valueStr); newValue = !newValue && !this.allowEmpty ? 0 : newValue; this.updateInput(newValue, insertedValueStr, operation, valueStr); - this.handleOnInput(event, currentValue, newValue); } }, @@ -891,9 +886,9 @@ export default { this._decimal.lastIndex = 0; if (this.suffixChar) { - return decimalCharIndex !== -1 ? val1.replace(this.suffixChar, '').split(this._decimal)[0] + val2.replace(this.suffixChar, '').slice(decimalCharIndex) + this.suffixChar : val1; + return decimalCharIndex !== -1 ? val1.replace(this.suffixChar, '').split(this._decimal)[0] + val2.replace(this.suffixChar, '').slice(decimalCharIndex) + this.suffixChar : val2; } else { - return decimalCharIndex !== -1 ? val1.split(this._decimal)[0] + val2.slice(decimalCharIndex) : val1; + return decimalCharIndex !== -1 ? val1.split(this._decimal)[0] + val2.slice(decimalCharIndex) : val2; } } From 2628c4e4a83c7bc96ff3506e765402e8c18ac896 Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Tue, 8 Oct 2024 20:26:01 +0900 Subject: [PATCH 2/5] fix: modify currencyDisplay to display the currency code --- packages/primevue/src/inputnumber/BaseInputNumber.vue | 2 +- packages/primevue/src/inputnumber/InputNumber.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/primevue/src/inputnumber/BaseInputNumber.vue b/packages/primevue/src/inputnumber/BaseInputNumber.vue index 8c9eb8ac1..b432bb99e 100644 --- a/packages/primevue/src/inputnumber/BaseInputNumber.vue +++ b/packages/primevue/src/inputnumber/BaseInputNumber.vue @@ -72,7 +72,7 @@ export default { }, currencyDisplay: { type: String, - default: undefined + default: 'code' }, useGrouping: { type: Boolean, diff --git a/packages/primevue/src/inputnumber/InputNumber.d.ts b/packages/primevue/src/inputnumber/InputNumber.d.ts index 13a0bedc6..150b46809 100755 --- a/packages/primevue/src/inputnumber/InputNumber.d.ts +++ b/packages/primevue/src/inputnumber/InputNumber.d.ts @@ -264,7 +264,7 @@ export interface InputNumberProps { currency?: string | undefined; /** * How to display the currency in currency formatting. Possible values are 'symbol' to use a localized currency symbol such as €, 'code' to use the ISO currency code, 'name' to use a localized currency name such as 'dollar'. - * @defaultValue symbol + * @defaultValue code */ currencyDisplay?: string | undefined; /** From 2a7b6b2fab9dc2e31cec4028d3db91118a318c5f Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Tue, 8 Oct 2024 20:30:33 +0900 Subject: [PATCH 3/5] chore: revert default value update --- packages/primevue/src/inputnumber/BaseInputNumber.vue | 2 +- packages/primevue/src/inputnumber/InputNumber.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/primevue/src/inputnumber/BaseInputNumber.vue b/packages/primevue/src/inputnumber/BaseInputNumber.vue index b432bb99e..8c9eb8ac1 100644 --- a/packages/primevue/src/inputnumber/BaseInputNumber.vue +++ b/packages/primevue/src/inputnumber/BaseInputNumber.vue @@ -72,7 +72,7 @@ export default { }, currencyDisplay: { type: String, - default: 'code' + default: undefined }, useGrouping: { type: Boolean, diff --git a/packages/primevue/src/inputnumber/InputNumber.d.ts b/packages/primevue/src/inputnumber/InputNumber.d.ts index 150b46809..13a0bedc6 100755 --- a/packages/primevue/src/inputnumber/InputNumber.d.ts +++ b/packages/primevue/src/inputnumber/InputNumber.d.ts @@ -264,7 +264,7 @@ export interface InputNumberProps { currency?: string | undefined; /** * How to display the currency in currency formatting. Possible values are 'symbol' to use a localized currency symbol such as €, 'code' to use the ISO currency code, 'name' to use a localized currency name such as 'dollar'. - * @defaultValue code + * @defaultValue symbol */ currencyDisplay?: string | undefined; /** From 200ae2ee009d5fb6006910017261cce7f4236c4e Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Tue, 8 Oct 2024 21:07:45 +0900 Subject: [PATCH 4/5] fix: resolve $el undefined error --- packages/primevue/src/select/Select.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/primevue/src/select/Select.vue b/packages/primevue/src/select/Select.vue index b1e0bf0d6..f99debcf0 100755 --- a/packages/primevue/src/select/Select.vue +++ b/packages/primevue/src/select/Select.vue @@ -690,7 +690,7 @@ export default { this.scrollInView(); setTimeout(() => { - this.autoFilterFocus && focus(this.$refs.filterInput.$el); + this.autoFilterFocus && this.filter && focus(this.$refs.filterInput.$el); }, 1); }, onOverlayAfterEnter() { From 849598f9bf276e5930c1f235ad83b1e69a941c1b Mon Sep 17 00:00:00 2001 From: KumJungMin Date: Tue, 8 Oct 2024 21:10:26 +0900 Subject: [PATCH 5/5] chore: revert unrelated change --- packages/primevue/src/inputnumber/InputNumber.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/primevue/src/inputnumber/InputNumber.vue b/packages/primevue/src/inputnumber/InputNumber.vue index 6565d252e..513c5a63e 100755 --- a/packages/primevue/src/inputnumber/InputNumber.vue +++ b/packages/primevue/src/inputnumber/InputNumber.vue @@ -424,7 +424,7 @@ export default { if (selectionStart === selectionEnd) { const deleteChar = inputValue.charAt(selectionStart - 1); - const { decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue); + const { decimalCharIndex, decimalCharIndexWithoutPrefix } = this.getDecimalCharIndexes(inputValue); if (this.isNumeralChar(deleteChar)) { const decimalLength = this.getDecimalLength(inputValue); @@ -440,6 +440,10 @@ export default { } else { newValueStr = inputValue.slice(0, selectionStart - 1) + inputValue.slice(selectionStart); } + } else if (decimalCharIndex > 0 && selectionStart > decimalCharIndex) { + const insertedText = this.isDecimalMode() && (this.minFractionDigits || 0) < decimalLength ? '' : '0'; + + newValueStr = inputValue.slice(0, selectionStart - 1) + insertedText + inputValue.slice(selectionStart); } else if (decimalCharIndexWithoutPrefix === 1) { newValueStr = inputValue.slice(0, selectionStart - 1) + '0' + inputValue.slice(selectionStart); newValueStr = this.parseValue(newValueStr) > 0 ? newValueStr : ''; @@ -767,6 +771,7 @@ export default { newValue = this.parseValue(valueStr); newValue = !newValue && !this.allowEmpty ? 0 : newValue; this.updateInput(newValue, insertedValueStr, operation, valueStr); + this.handleOnInput(event, currentValue, newValue); } }, @@ -886,9 +891,9 @@ export default { this._decimal.lastIndex = 0; if (this.suffixChar) { - return decimalCharIndex !== -1 ? val1.replace(this.suffixChar, '').split(this._decimal)[0] + val2.replace(this.suffixChar, '').slice(decimalCharIndex) + this.suffixChar : val2; + return decimalCharIndex !== -1 ? val1.replace(this.suffixChar, '').split(this._decimal)[0] + val2.replace(this.suffixChar, '').slice(decimalCharIndex) + this.suffixChar : val1; } else { - return decimalCharIndex !== -1 ? val1.split(this._decimal)[0] + val2.slice(decimalCharIndex) : val2; + return decimalCharIndex !== -1 ? val1.split(this._decimal)[0] + val2.slice(decimalCharIndex) : val1; } }