fix(components): [input-number] fix default value reset error (#15725) (#15725)

* fix(components): [input-number] fix default value reset error

* test(components): [input-number] fix value default value reset error
This commit is contained in:
希亚的西红柿
2024-02-27 17:48:17 +08:00
committed by GitHub
parent 9785ad1cd0
commit 33f41f7795
2 changed files with 6 additions and 2 deletions

View File

@@ -429,6 +429,8 @@ describe('InputNumber.vue', () => {
elInput.handleInputChange('')
await nextTick()
expect(num.value).toBe(5)
await wrapper.find('input').setValue('')
expect(num.value).toBe(5)
elInput.decrease()
await nextTick()
expect(num.value).toBe(4)

View File

@@ -239,10 +239,12 @@ const setCurrentValue = (
emit(UPDATE_MODEL_EVENT, newVal!)
return
}
if (oldVal === newVal) return
if (oldVal === newVal && value) return
data.userInput = null
emit(UPDATE_MODEL_EVENT, newVal!)
emit(CHANGE_EVENT, newVal!, oldVal!)
if (oldVal !== newVal) {
emit(CHANGE_EVENT, newVal!, oldVal!)
}
if (props.validateEvent) {
formItem?.validate?.('change').catch((err) => debugWarn(err))
}