mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(multi-select): avoid runtime error if items
is empty (#1577)
This commit is contained in:
parent
09b3eed582
commit
4b503c8c35
1 changed files with 1 additions and 0 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue