Skip to content

Commit

Permalink
Merge pull request #265 from jwmann/fix/highlight-select
Browse files Browse the repository at this point in the history
Pass filtered options to useHighlight instead of all options.
  • Loading branch information
tbleckert authored Oct 10, 2023
2 parents 6639c27 + 2b52b6e commit 02429ad
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/useSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ export default function useSelect({
}, 0);
};

const [keyHandlers, highlighted, setHighlighted] = useHighlight(
options,
onSelect,
ref,
);
const middleware = [
useFuzzySearch ? fuzzySearch : null,
...(filterOptions ? filterOptions : []),
];
const filteredOptions = groupOptions(reduce(middleware, options, q));
const [keyHandlers, highlighted, setHighlighted] = useHighlight(
filteredOptions,
onSelect,
ref,
);

const snapshot = {
search: q,
Expand All @@ -75,7 +76,7 @@ export default function useSelect({
value: getValue(option),
fetching,
highlighted,
options: groupOptions(reduce(middleware, options, q)),
options: filteredOptions,
displayValue: getDisplayValue(option, options, placeholder),
};

Expand Down

1 comment on commit 02429ad

@vercel
Copy link

@vercel vercel bot commented on 02429ad Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.