fix: InputNumber unexpected behavior when using allow-empty attribute combined with min attribute.

pull/7044/head
minekuba 2025-01-04 01:38:41 +01:00
parent 81966b9b39
commit 600e36aab1
1 changed files with 11 additions and 3 deletions

View File

@ -782,8 +782,16 @@ export default {
if (valueStr != null) {
newValue = this.parseValue(valueStr);
newValue = !newValue && !this.allowEmpty ? 0 : newValue;
this.updateInput(newValue, insertedValueStr, operation, valueStr);
if (!newValue && !this.allowEmpty) {
newValue = 0;
this.updateInput(newValue, insertedValueStr, operation, valueStr);
const cursorPos = this.prefix ? this.prefix.length + 1 : 1;
this.$refs.input.$el.setSelectionRange(cursorPos, cursorPos);
} else {
this.updateInput(newValue, insertedValueStr, operation, valueStr);
}
this.handleOnInput(event, currentValue, newValue);
}
@ -864,7 +872,7 @@ export default {
this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
} else if (newLength === currentLength) {
if (operation === 'insert' || operation === 'delete-back-single') {
this.$refs.input.$el.setSelectionRange(selectionEnd + 1, selectionEnd + 1);
this.$refs.input.$el.setSelectionRange(selectionEnd, selectionEnd);
} else if (operation === 'delete-single') {
this.$refs.input.$el.setSelectionRange(selectionEnd - 1, selectionEnd - 1);
} else if (operation === 'delete-range' || operation === 'spin') {