Skip to content

Commit

Permalink
fix(autocomplete): highlight item in AutocompleteSection during key…
Browse files Browse the repository at this point in the history
…board navigation (#3726)
  • Loading branch information
chirokas authored Sep 7, 2024
1 parent 985c2e1 commit d621b29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-baboons-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/listbox": patch
---

Fix item highlighting in `AutocompleteSection` during keyboard navigation (#3713)
10 changes: 3 additions & 7 deletions packages/components/listbox/src/use-listbox-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,9 @@ export function useListboxItem<T extends object>(originalProps: UseListboxItemPr
itemProps = removeEvents(itemProps);
}

const isHighlighted = useMemo(() => {
if (shouldHighlightOnFocus && isFocused) {
return true;
}

return isMobile ? isHovered || isPressed : isHovered;
}, [isHovered, isPressed, isFocused, isMobile, shouldHighlightOnFocus]);
const isHighlighted =
(shouldHighlightOnFocus && isFocused) ||
(isMobile ? isHovered || isPressed : isHovered || (isFocused && !isFocusVisible));

const getItemProps: PropGetter = (props = {}) => ({
ref: domRef,
Expand Down

0 comments on commit d621b29

Please sign in to comment.