Skip to content

Commit

Permalink
next: fix nav menu focus (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Sep 27, 2024
1 parent b8f256c commit a4a3ec6
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AccordionBaseState {
this.#loop = props.loop;
this.rovingFocusGroup = useRovingFocus({
rootNodeId: this.#id,
candidateSelector: ACCORDION_TRIGGER_ATTR,
candidateAttr: ACCORDION_TRIGGER_ATTR,
loop: this.#loop,
orientation: this.orientation,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/menu/menu.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class MenuContentState {
this.#handleTypeaheadSearch = useTypeahead().handleTypeaheadSearch;
this.rovingFocusGroup = useRovingFocus({
rootNodeId: this.parentMenu.contentId,
candidateSelector: this.parentMenu.root.attrs.item,
candidateAttr: this.parentMenu.root.attrs.item,
loop: this.#loop,
orientation: box.with(() => "vertical"),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/menubar/menubar.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MenubarRootState {
});
this.rovingFocusGroup = useRovingFocus({
rootNodeId: this.id,
candidateSelector: TRIGGER_ATTR,
candidateAttr: TRIGGER_ATTR,
loop: this.loop,
orientation: box.with(() => "horizontal"),
currentTabStopId: this.currentTabStopId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
let {
id = useId(),
value = useId(),
ref = $bindable(null),
child,
children,
ref = $bindable(),
...restProps
}: ItemProps = $props();
const itemState = useNavigationMenuItem({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
value: box.with(() => value),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let {
id = useId(),
ref = $bindable(),
ref = $bindable(null),
child,
children,
active = false,
Expand All @@ -18,6 +18,10 @@
const linkState = useNavigationMenuLink({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
active: box.with(() => active),
onSelect: box.with(() => onSelect),
});
Expand Down
Loading

0 comments on commit a4a3ec6

Please sign in to comment.