fix(components): [select & select-v2] remove-tag when use backspace (#16832)

This commit is contained in:
Liao-js 2024-05-21 16:51:00 +08:00 committed by GitHub
parent b905cc00aa
commit 1f4ca71c7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -582,11 +582,13 @@ const useSelect = (props: ISelectV2Props, emit) => {
const selected = (props.modelValue as Array<any>).slice()
const lastNotDisabledIndex = getLastNotDisabledIndex(selected)
if (lastNotDisabledIndex < 0) return
const removeTagValue = selected[lastNotDisabledIndex]
selected.splice(lastNotDisabledIndex, 1)
const option = states.cachedOptions[lastNotDisabledIndex]
states.cachedOptions.splice(lastNotDisabledIndex, 1)
removeNewOption(option)
update(selected)
emit('remove-tag', removeTagValue)
}
}

View File

@ -504,9 +504,11 @@ export const useSelect = (props: ISelectProps, emit) => {
const value = props.modelValue.slice()
const lastNotDisabledIndex = getLastNotDisabledIndex(value)
if (lastNotDisabledIndex < 0) return
const removeTagValue = value[lastNotDisabledIndex]
value.splice(lastNotDisabledIndex, 1)
emit(UPDATE_MODEL_EVENT, value)
emitChange(value)
emit('remove-tag', removeTagValue)
}
}