-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search: default Sphinx's search doesn't work when addons is enabled #213
Search: default Sphinx's search doesn't work when addons is enabled #213
Comments
Using #217 approach, I tested this with the official Sphinx's documentation and I was able to reproduce the issue. I noticed some JS conflict, but I'm not 100% where it is. When loading
|
Actually, not being able to populate the input field is the main reason why it doesn't work. The Sphinx code gets the |
I found the issue! 🎉 The problem is our The explanation of the problem is that we are removing the If you open https://jdaviz.readthedocs.io/en/latest/_static/searchtools.js and go to the bottom of that file, you will see:
instead of We can't kill this extension right now, unfortunately. So, we should find a way to support both scenarios: addons enabled/disabled. Besides, I don't want to loose the ability to enable/disable addons without rebuilding your docs. With these things in mind, my proposal to fix this problem is to adapt the javascript replaced to support both cases:
I will open a PR with this changes, but it should be simple enough. This will allow us to keep both scenarios working and break nothing once we remove completely our Sphinx extension. |
The extension removes the call to `Search.init` because it needs to perform some injection before calling this method. The old implementation of the `readthedocs-doc-embed.js` calls this method manually after modifying some stuff. However, with the introduction of addons, we don't want to manipulate the defaults and the Sphinx default search should work out-of-the-box. To keep the default behavior when addons is enabled, we check for addons javascript and if it's present we call `_ready(Search.init);` as the default Sphinx code does. See readthedocs/addons#213 for more information.
The extension removes the call to `Search.init` because it needs to perform some injection before calling this method. The old implementation of the `readthedocs-doc-embed.js` calls this method manually after modifying some stuff. However, with the introduction of addons, we don't want to manipulate the defaults and the Sphinx default search should work out-of-the-box. To keep the default behavior when addons is enabled, we check for addons javascript and if it's present we call `_ready(Search.init);` as the default Sphinx code does. See readthedocs/addons#213 for more information.
* Keep default `Search.init` behavior if addons injected The extension removes the call to `Search.init` because it needs to perform some injection before calling this method. The old implementation of the `readthedocs-doc-embed.js` calls this method manually after modifying some stuff. However, with the introduction of addons, we don't want to manipulate the defaults and the Sphinx default search should work out-of-the-box. To keep the default behavior when addons is enabled, we check for addons javascript and if it's present we call `_ready(Search.init);` as the default Sphinx code does. See readthedocs/addons#213 for more information. * Update test case * Lint * Update integration test * Wait for the DOM to be ready before checking for the `script`
This is already working fine at https://docs.astropy.org/en/latest/search.html?q=coordinates |
The default Sphinx's search works fine on this project https://jdaviz.readthedocs.io/en/latest/search.html?q=imviz (the same happens with https://docs.astropy.org/en/latest/search.html?q=test). However, if the addons are enabled on that project, it fails. The JS console doesn't report anything, so I'm not sure yet what's the exact problem.
See astropy/astropy#15459 for more information.
The text was updated successfully, but these errors were encountered: