yury-dymov / react-autocomplete-input

Autocomplete input field for React
https://yury-dymov.github.io/react-autocomplete-input/
MIT License
199 stars 65 forks source link

Use external search engine #33

Closed millette closed 1 year ago

millette commented 5 years ago

This is slightly related to #18 but more generic.

I'm using minisearch for client-side search and it also provides autocomplete suggestions.

I'd like to use minisearch (really, any similar function) to provide the suggestions dynamically. Not sure yet how the two would tie up but I'm going to try a PR and see what happens as my explanation probably isn't clear enough...

yury-dymov commented 5 years ago

Sure, I will gladly review such PR!

millette commented 5 years ago

I've starting working on it but I've been pretty distracted today. Hope to have something to show tomorrow.

millette commented 5 years ago

Turns out it almost works out of the box.

Without modifying your module, I have this demo: https://millette.github.io/tauto/

Source: https://github.com/millette/tauto/

It's basically your demo but I replaced the options with a call to https://lucaong.github.io/minisearch/class/src/MiniSearch.js~MiniSearch.html#instance-method-autoSuggest but you'll notice onRequestOptions is just called once after the first character.

I'm not really sure what would be the best way to proceed to have options updated with every keystroke. Suggestions?

yury-dymov commented 5 years ago

I think requestOnlyIfNoOptions prop controls this behavior. At least, it should :)

millette commented 5 years ago

From what I've seen, onRequestOptions is only called when typing in the textarea. When the choices pop-up, we're typing in another scope, whether requestOnlyIfNoOptions is true or false.

yury-dymov commented 1 year ago

Closing due to inactivity