mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix(components): [input-number] modelValue incorrect update (#12007)
This commit is contained in:
parent
7987f6f73e
commit
b5bf0ebf30
@ -47,6 +47,7 @@ describe('InputNumber.vue', () => {
|
||||
'null'
|
||||
)
|
||||
})
|
||||
|
||||
// fix: #10328
|
||||
test('Make sure the input action can trigger the modelValue update', async () => {
|
||||
const num = ref<number>(0)
|
||||
@ -65,6 +66,20 @@ describe('InputNumber.vue', () => {
|
||||
await nextTick()
|
||||
expect(num.value).toEqual(3)
|
||||
})
|
||||
|
||||
// fix: #11963
|
||||
test('Make sure modelValue correct update when no initial value', async () => {
|
||||
const num = ref<number>()
|
||||
const wrapper = mount(() => <InputNumber v-model={num.value} />)
|
||||
const inputWrapper = wrapper.find('input')
|
||||
const nativeInput = inputWrapper.element
|
||||
nativeInput.value = '1'
|
||||
await inputWrapper.trigger('input')
|
||||
nativeInput.value = ''
|
||||
await inputWrapper.trigger('input')
|
||||
expect(num.value).toEqual(null)
|
||||
})
|
||||
|
||||
test('min', async () => {
|
||||
const num = ref(1)
|
||||
const wrapper = mount(() => <InputNumber min={3} v-model={num.value} />)
|
||||
|
@ -224,11 +224,11 @@ const setCurrentValue = (
|
||||
) => {
|
||||
const oldVal = data.currentValue
|
||||
const newVal = verifyValue(value)
|
||||
if (oldVal === newVal) return
|
||||
if (!emitChange) {
|
||||
emit(UPDATE_MODEL_EVENT, newVal!)
|
||||
return
|
||||
}
|
||||
if (oldVal === newVal) return
|
||||
data.userInput = null
|
||||
emit(UPDATE_MODEL_EVENT, newVal!)
|
||||
emit(CHANGE_EVENT, newVal!, oldVal!)
|
||||
|
Loading…
Reference in New Issue
Block a user