diff --git a/packages/components/select-v2/src/useSelect.ts b/packages/components/select-v2/src/useSelect.ts index ea9fbd6d8a..4dd97863aa 100644 --- a/packages/components/select-v2/src/useSelect.ts +++ b/packages/components/select-v2/src/useSelect.ts @@ -669,17 +669,11 @@ const useSelect = (props: ISelectV2Props, emit) => { return getValueKey(item) === getValueKey(props.modelValue) }) } else { - if (props.modelValue.length > 0) { - states.hoveringIndex = Math.min( - ...props.modelValue.map((selected) => { - return filteredOptions.value.findIndex((item) => { - return getValue(item) === selected - }) - }) + states.hoveringIndex = filteredOptions.value.findIndex((item) => + props.modelValue.some( + (modelValue) => getValueKey(modelValue) === getValueKey(item) ) - } else { - states.hoveringIndex = -1 - } + ) } } diff --git a/packages/components/select/src/useSelect.ts b/packages/components/select/src/useSelect.ts index b8439c7e70..3fdd3e3443 100644 --- a/packages/components/select/src/useSelect.ts +++ b/packages/components/select/src/useSelect.ts @@ -453,17 +453,11 @@ export const useSelect = (props: ISelectProps, emit) => { return getValueKey(item) === getValueKey(states.selected) }) } else { - if (states.selected.length > 0) { - states.hoveringIndex = Math.min( - ...states.selected.map((selected) => { - return optionsArray.value.findIndex((item) => { - return getValueKey(item) === getValueKey(selected) - }) - }) + states.hoveringIndex = optionsArray.value.findIndex((item) => + states.selected.some( + (selected) => getValueKey(selected) === getValueKey(item) ) - } else { - states.hoveringIndex = -1 - } + ) } }