Skip to content

Commit

Permalink
fix(Dropdown): no more focus errors if Dropdown.Items.Item is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
N00nDay committed Apr 27, 2023
1 parent 5baec04 commit cbdc419
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/components/dropdown/Items.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
e.stopPropagation();
if (e.key === 'ArrowUp') {
focusIndex = focusIndex > 0 ? focusIndex - 1 : items.length - 1;
items[focusIndex].focus();
if (items && items[focusIndex]) items[focusIndex].focus();
} else if (e.key === 'ArrowDown') {
focusIndex = focusIndex < items.length - 1 ? focusIndex + 1 : 0;
items[focusIndex].focus();
} else if (e.key === 'Enter') {
console.log('Enter FIRED');
if (items && items[focusIndex]) items[focusIndex].focus();
} else if (e.key === 'Escape') {
handleClose();
}
Expand Down Expand Up @@ -80,7 +78,7 @@
onMount(() => {
items = list.querySelectorAll('li');
items[focusIndex].focus();
if (items && items[focusIndex]) items[focusIndex].focus();
});
</script>

Expand Down

1 comment on commit cbdc419

@vercel
Copy link

@vercel vercel bot commented on cbdc419 Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

stwui – ./

stwui.vercel.app
stwui-git-main-n00nday.vercel.app
stwui-n00nday.vercel.app

Please sign in to comment.