You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
autoHighlight is not always highlighting the top match #239
The top match is only highlighted if it is compared to a String with the exact same beginning.
For Example if I want to search for "123" it will only be highlighted if I enter "1" and it is not being highlighted if I write "2" or "3" in the input field.
Reacted by Ryan Sullivan, im1dermike and Naia Bouscal
The current implementation is equivalent to String#startsWith. We don't have any plans to change this in v1, but it is on our things to consider for future versions.
It's not difficult, we just don't intend on changing the behaviour at the moment. When we eventually do, we will want to create something that is flexible enough to cater to different needs, and not just a single use case.
@CMTegner - I've forked the repo, added a predicate support, which is essentially a function receiving itemValue: String and inputValue: String and should return a boolean result,
You can see it here: master...madlandev:master
It's not possible for me to create a fork since I've included the build files for our own modules, but should you desire, I can create one for you guys.
I've found a "solution" for my use case, I just want it to select the first in the list by default, so that the user can hit enter and it will select the first in the list, for the getItemValue(item) just return the input query, that way the first always matches the default match and is selected until the user starts navigating with the arrow keys.
It's not pretty but it works for my use case :)
Activity
CMTegner commentedon May 25, 2017
The current implementation is equivalent to
String#startsWith. We don't have any plans to change this in v1, but it is on our things to consider for future versions.silicakes commentedon Aug 7, 2017
@CMTegner - i see the line right here:
https://github.com/reactjs/react-autocomplete/blob/master/lib/Autocomplete.js#L352
Why is it difficult to change it to something like:
CMTegner commentedon Aug 7, 2017
It's not difficult, we just don't intend on changing the behaviour at the moment. When we eventually do, we will want to create something that is flexible enough to cater to different needs, and not just a single use case.
silicakes commentedon Aug 8, 2017
@CMTegner - I've forked the repo, added a predicate support, which is essentially a function receiving
itemValue: StringandinputValue: Stringand should return a boolean result,You can see it here:
master...madlandev:master
It's not possible for me to create a fork since I've included the build files for our own modules, but should you desire, I can create one for you guys.
ryansully commentedon Jan 10, 2018
@silicakes Would you be interested in submitting a PR with your changes to implement this? It seems like it should be expected functionality.
BeauCarrel commentedon Nov 13, 2018
I've found a "solution" for my use case, I just want it to select the first in the list by default, so that the user can hit enter and it will select the first in the list, for the getItemValue(item) just return the input query, that way the first always matches the default match and is selected until the user starts navigating with the arrow keys.
It's not pretty but it works for my use case :)