Is there a way to only turn the autocomplete on after typing lets say three keystrokes? I am currently using the react library react-select.
Asked
Active
Viewed 1,874 times
1
-
are you also using https://github.com/reactjs/react-autocomplete ? – Nevosis Aug 08 '17 at 08:08
-
@Nevosis No, I am solely using react-select – Ben Bieler Aug 08 '17 at 08:13
1 Answers
1
I would implement to execute asynchronous event after (around) 300ms rather than counting each keystrokes. You can have a look at debounce
and persist
in here

An Nguyen
- 1,487
- 10
- 21
-
Thanks - Well I would like to count the keystrokes. But how can you call the function to trigger the dropdown? Or how can you prevent the dropdown from showing? – Ben Bieler Aug 10 '17 at 12:30
-
1You can try `filterOption`: https://github.com/JedWatson/react-select#filtering-options. I think counting the `filter.length` and `return false` should works. – An Nguyen Aug 10 '17 at 14:34
-
Thank you for your help! Now the dropdown appears after the third keystroke - prior to that it is disabled. But now the search is not working. Do you know why this could be the case? – Ben Bieler Aug 11 '17 at 10:13
-
1Does this (or similar) : `filterOption(option, filter) { return (filter.length % 3) === 0 ? true : false }` solve your issue ? – An Nguyen Aug 11 '17 at 10:34