mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(dropdown): avoid runtime error if items
is empty (#1578)
This commit is contained in:
parent
4b503c8c35
commit
fce92fb648
1 changed files with 1 additions and 0 deletions
|
@ -121,6 +121,7 @@
|
||||||
function change(dir) {
|
function change(dir) {
|
||||||
let index = highlightedIndex + dir;
|
let index = highlightedIndex + dir;
|
||||||
|
|
||||||
|
if (items.length === 0) return;
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index = items.length - 1;
|
index = items.length - 1;
|
||||||
} else if (index >= items.length) {
|
} else if (index >= items.length) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue