Skip to content

Commit

Permalink
Merge pull request #5672 from matuzalemsteles/LPS-194107
Browse files Browse the repository at this point in the history
fix(@clayui/autocomplete): fix error when navigating via keyboard with the mouse over the item
  • Loading branch information
matuzalemsteles authored Sep 15, 2023
2 parents 40b4301 + f3927d5 commit b64ac0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
statements: 100,
},
'./packages/clay-autocomplete/src/': {
branches: 68,
branches: 67,
functions: 82,
lines: 85,
statements: 85,
Expand Down
9 changes: 6 additions & 3 deletions packages/clay-autocomplete/src/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ const NewItem = React.forwardRef<HTMLLIElement, IProps>(function NewItem(
const {activeDescendant, onActiveDescendant} = useAutocompleteState();
const {isFocusVisible} = useInteractionFocus();

const isFocus = isFocusVisible();

const hoverProps = useHover({
disabled,
onHover: useCallback(() => onActiveDescendant(keyValue!), [keyValue]),
onHover: useCallback(
() => !isFocus && onActiveDescendant(keyValue!),
[keyValue, isFocus]
),
});

const isFocus = isFocusVisible();

const currentValue = textValue ?? value ?? String(children);
const fuzzyMatch = fuzzy.match(match, currentValue, optionsFuzzy);

Expand Down

0 comments on commit b64ac0a

Please sign in to comment.