fix(components): [select-v2] pressing the up key may cause errors (#9818)

This commit is contained in:
qiang 2022-09-20 11:01:49 +08:00 committed by GitHub
parent cb387540a6
commit c2cec13bf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -559,7 +559,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
}
} else if (direction === 'backward') {
newIndex = hoveringIndex - 1
if (newIndex < 0) {
if (newIndex < 0 || newIndex >= options.length) {
// navigate to the last one
newIndex = options.length - 1
}