Skip to content

Commit d621b29

Browse files
authoredSep 7, 2024··
fix(autocomplete): highlight item in AutocompleteSection during keyboard navigation (#3726)
1 parent 985c2e1 commit d621b29

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
 

‎.changeset/popular-baboons-pull.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nextui-org/listbox": patch
3+
---
4+
5+
Fix item highlighting in `AutocompleteSection` during keyboard navigation (#3713)

‎packages/components/listbox/src/use-listbox-item.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,9 @@ export function useListboxItem<T extends object>(originalProps: UseListboxItemPr
109109
itemProps = removeEvents(itemProps);
110110
}
111111

112-
const isHighlighted = useMemo(() => {
113-
if (shouldHighlightOnFocus && isFocused) {
114-
return true;
115-
}
116-
117-
return isMobile ? isHovered || isPressed : isHovered;
118-
}, [isHovered, isPressed, isFocused, isMobile, shouldHighlightOnFocus]);
112+
const isHighlighted =
113+
(shouldHighlightOnFocus && isFocused) ||
114+
(isMobile ? isHovered || isPressed : isHovered || (isFocused && !isFocusVisible));
119115

120116
const getItemProps: PropGetter = (props = {}) => ({
121117
ref: domRef,

0 commit comments

Comments
 (0)
Please sign in to comment.