mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 19:28:14 +08:00
fix: selet-v2 value-key mode selected style and onClonse bug (#6602)
* fix: selet-v2 value-key mode selected style and onClonse bug * style: format Co-authored-by: xiaochenchen <xiaochen.chen@igg.com>
This commit is contained in:
parent
bb939c6a58
commit
dba6a63e20
@ -82,10 +82,11 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const isItemSelected = (modelValue: any[] | any, target: Option) => {
|
||||
const { valueKey } = select.props
|
||||
if (select.props.multiple) {
|
||||
return contains(modelValue, target.value)
|
||||
return contains(modelValue, get(target, valueKey))
|
||||
}
|
||||
return isEqual(modelValue, target.value)
|
||||
return isEqual(modelValue, get(target, valueKey))
|
||||
}
|
||||
|
||||
const isItemDisabled = (modelValue: any[] | any, selected: boolean) => {
|
||||
|
@ -451,7 +451,8 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
}
|
||||
|
||||
const deleteTag = (event: MouseEvent, tag: Option) => {
|
||||
const index = (props.modelValue as Array<any>).indexOf(tag.value)
|
||||
const { valueKey } = props
|
||||
const index = (props.modelValue as Array<any>).indexOf(get(tag, valueKey))
|
||||
|
||||
if (index > -1 && !selectDisabled.value) {
|
||||
const value = [
|
||||
@ -460,7 +461,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
]
|
||||
states.cachedOptions.splice(index, 1)
|
||||
update(value)
|
||||
emit('remove-tag', tag.value)
|
||||
emit('remove-tag', get(tag, valueKey))
|
||||
states.softFocus = true
|
||||
removeNewOption(tag)
|
||||
return nextTick(focusAndUpdatePopup)
|
||||
|
Loading…
Reference in New Issue
Block a user