Skip to content

Commit

Permalink
Merge branch 'develop' into anchored-overlay-focus-trap
Browse files Browse the repository at this point in the history
  • Loading branch information
scurker authored Dec 19, 2024
2 parents 80fbbdd + 897963b commit 80fd257
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/react/src/components/Listbox/Listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,19 @@ const Listbox = forwardRef<
)
);
setSelectedOptions(matchingOptions);
setActiveOption(matchingOptions[0] || null);
if (!activeOption) {
setActiveOption(matchingOptions[0] || null);
}
} else {
const matchingOption = options.find((option) =>
optionMatchesValue(option, listboxValue)
);
setSelectedOptions(matchingOption ? [matchingOption] : []);
setActiveOption(matchingOption || null);
if (!activeOption) {
setActiveOption(matchingOption || null);
}
}
}, [isControlled, options, value, defaultValue]);
}, [isControlled, options, value, defaultValue, activeOption]);

useEffect(() => {
if (activeOption) {
Expand Down

0 comments on commit 80fd257

Please sign in to comment.