algolia / docsearch

:blue_book: The easiest way to add search to your documentation.
https://docsearch.algolia.com
MIT License
3.98k stars 385 forks source link

Key listener issues in SPA #1363

Open Mister-Hope opened 2 years ago

Mister-Hope commented 2 years ago

Hi, this is Mr.Hope from VuePress Team.

Docsearch is not providing a method to destory itself or any way to customize (or remove) the search key listener in docs. So I wonder if there is a way, otherwise this will trigger error in SPA application, as each initialization will have side effects which can not be cleared.

Visit https://mister-hope.com/ and scroll down then click the first article. When you click Ctrl + K, you will find 2 docsearch popup is displayed.

In VuePress, we are using SPA and provide "layout" options, different page may choose different layout. So when you switch to the first article, the whole page is rerendered because they have different layout, so docsearch reinitializes. But the previous key listener seems still exist, so keyboard actions seems not correct.

Mister-Hope commented 2 years ago

Hi, any update with this one? Can we add a detroy method to clear docsearch event listener and destory the dom?

Mister-Hope commented 1 year ago

Hello?

shortcuts commented 1 year ago

(Hey there, sorry for the delay, added context here https://github.com/algolia/docsearch/issues/1734)

If you feel like contributing/providing the method, I'd be more than happy to review it!

Mister-Hope commented 1 year ago

Sure, I will try to build a destory method if possible.

I just want to make sure if this sounds ok to you before starting contribution.

Mister-Hope commented 7 months ago

Hi, any update about this one? I am still meeting users reporting this frequently.

I opened PR years ago https://github.com/algolia/docsearch/pull/1742, while I am not getting any review.

@shortcuts @francoischalifour