fix(multi-select): avoid runtime error if items is empty (#1577)

This commit is contained in:
metonym 2022-12-07 20:34:46 -08:00 committed by GitHub
commit 4b503c8c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -203,6 +203,7 @@
function change(direction) { function change(direction) {
let index = highlightedIndex + direction; let index = highlightedIndex + direction;
const length = filterable ? filteredItems.length : items.length; const length = filterable ? filteredItems.length : items.length;
if (length === 0) return;
if (index < 0) { if (index < 0) {
index = length - 1; index = length - 1;
} else if (index >= length) { } else if (index >= length) {