docsearch icon indicating copy to clipboard operation
docsearch copied to clipboard

Initializing Docsearch more than once creates multiple overlapping autocomplete drop downs

Open bbusch19 opened this issue 5 years ago • 4 comments

Do you want to request a feature or report a bug? Feature

What is the current behavior? When calling window.docsearch({...options}) multiple times, multiple autocomplete dropdowns are added to the UI.

If the current behavior is a bug, please provide all the steps to reproduce and a minimal [JSFiddle][3] example or a repository on GitHub that we can npm install and npm start.

What is the expected behavior? I need to be able to apply filters to the search based on user selection. I'm not sure if this is currently possible. I have tried to call window.docsearch({...options}) when the user picks a category to search by, but that seems to add multiple autocomplete dropdowns instead of refreshing the current instance. It would be nice if you could refresh the autocomplete dropdown with results from a newly filtered index.

bbusch19 avatar Feb 14 '20 22:02 bbusch19

If I understand correctly, you want to target another DocSearch index after a user interaction. Since the API doesn't allow you to change the index, you tried adding two instances of docsearch in the same container, and each instance are appended instead of replaced. Is that right?

If I got that wrong, it would be helpful to reproduce the behavior in this DocSearch sandbox.

francoischalifour avatar Feb 17 '20 09:02 francoischalifour

@francoischalifour Yes that is correct. Thank you for rephrasing that.

bbusch19 avatar Feb 17 '20 16:02 bbusch19

That is not possible with the current API. However, you can run two instances of DocSearch and hide/remove the ones with the previous options.

Thanks for the feedback, this is something that we might want to cover in the next version.

francoischalifour avatar Feb 18 '20 15:02 francoischalifour

I would very much like to have a api that uninstalls docsearch instance. My project will switch multiple docsearch instance according to the language.

zicjin avatar Feb 23 '20 09:02 zicjin