fix(autocomplete): highlight item in AutocompleteSection during keyboard navigation (#3726)

This commit is contained in:
chirokas 2024-09-07 22:59:00 +08:00 committed by GitHub
parent 985c2e1dd3
commit d621b2923e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"@nextui-org/listbox": patch
---
Fix item highlighting in `AutocompleteSection` during keyboard navigation (#3713)

View File

@ -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,