Skip to content

Commit 74f0785

Browse files
committed
simplify null checks
1 parent 623aa63 commit 74f0785

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

frontend/src/components/floating-menus/MenuList.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
await tick();
9898
9999
const flattened = filteredEntries.flat();
100-
const highlightedFound = highlighted?.value && flattened.map((entry) => entry.value).includes(highlighted.value);
100+
const highlightedFound = flattened.map((entry) => entry.value).includes(highlighted.value);
101101
const newHighlighted = highlightedFound ? highlighted : flattened[0];
102102
setHighlighted(newHighlighted);
103103
}
@@ -335,7 +335,7 @@
335335
if ((menuOpen || interactive) && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
336336
let newIndex = e.key === "ArrowUp" ? flatEntries.length - 1 : 0;
337337
if (highlighted) {
338-
const index = highlighted ? flatEntries.map((entry) => entry.value).indexOf(highlighted.value) : 0;
338+
const index = flatEntries.map((entry) => entry.value).indexOf(highlighted.value);
339339
newIndex = index + (e.key === "ArrowUp" ? -1 : 1);
340340
341341
// Interactive dropdowns should lock at the end whereas other dropdowns should loop

0 commit comments

Comments
 (0)