Initializing docsearch does not always work
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 439
- Avg merge
- 14h 32m
- Merged PRs (30d)
- 19
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When calling window.docsearch({...options}) the event listener is not caught on the input and the search does not work. Calling window.docsearch() a second time fixes the issue.
What we currently do is on the loading of the page we create and add to the DOM using javascript an input element, wait 1 second and then call window.docsearch()
This reproduce for some users and some users have it working properly.
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.
https://github.com/Rookout/docs
You can `cd website && npm install && npm start` to start the website.
The relevant code is located at:
https://github.com/Rookout/docs/blob/master/website/static/js/rookoutCustom.js - line 52
https://github.com/Rookout/docs/blob/master/website/static/js/algoliaSearchRookout.js
What is the expected behavior?
I would expect to call window.docsearch() once and the search should work.
Contributor guide
Research direction
Start with website/static/js/rookoutCustom.js at line 52 and website/static/js/algoliaSearchRookout.js in the linked Rookout/docs reproduction; run cd website && npm install && npm start. Trace why the input listener is missed on the first window.docsearch({...options}) call, then verify that a single initialization makes search work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100