Skip to content

Commit 100ecc3

Browse files
combined if statements and added early return
Thanks to Greg, we've combined the if-statement and added a more explicit early return. It should be more readable now.
1 parent ac9fef3 commit 100ecc3

File tree

1 file changed

+6
-5
lines changed
  • packages/kit-headless/src/components/select

1 file changed

+6
-5
lines changed

packages/kit-headless/src/components/select/select.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,22 @@ export const SelectRoot = component$(
7171
const listBox = track(() => contextService.listBoxRef.value);
7272
const expanded = track(() => isExpanded.value);
7373

74-
if (expanded && trigger && listBox) {
74+
if (!trigger || !listBox) return;
75+
76+
if (expanded === true) {
7577
listBox.style.visibility = 'hidden';
7678

7779
await updatePosition(trigger, listBox);
7880

7981
listBox.style.visibility = 'visible';
82+
83+
listBox?.focus();
8084
}
8185

86+
8287
if (expanded === false) {
8388
trigger?.focus();
8489
}
85-
86-
if (expanded === true) {
87-
listBox?.focus();
88-
}
8990
});
9091

9192
useOnWindow(

0 commit comments

Comments
 (0)