Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

[added] Configurable autoHighlightValueMatches function #387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

david-davidson
Copy link

Hi there, and thanks for this great library!

My team has an interesting use case. We're rendering a typeahead menu where the last item is always an entry to the effect of "Don't see what you're looking for?". We're using autoHighlight: true to keep the first menu item highlighted. When the user types a string with no matches—say, "asasdfasdf"—the menu contains just the single "Don't see what you're looking for?" entry... but it's not highlighted (and therefore not selectable with Enter), because the logic for checking whether the first item should be highlighted assumes an exact string match at index 0.

This PR adds a new autoHighlightValueMatches prop, allowing developers to override that logic. The prop is optional; if not provided, it defaults to the current behavior.

I can think of a couple other possible use cases:

  • Menu items are generated via fuzzy search, and the consumer prefers to use .includes() rather than indexOf() === 0 to determine match-iness.
  • Menu items are formatted with curly quotes/apostrophes, and consumer wants to handle user input with straight quotes/apostrophes.

Please let me know if you have any questions here. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant