Skip to content
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 results shows up with Please activate JavaScript ... error #132

Open
pradeepchawda opened this issue Jan 20, 2023 · 11 comments
Open

Comments

@pradeepchawda
Copy link

We have been facing issue with one of the repo where even if javascript is enabled it shows the warning as well as results.

Is this a known issue? If yes, what is is recommended fix? If not, then can any one suggest a fix.

image

@bashtage
Copy link
Owner

Not sure why you are seeing this. I don't see it. Which browser? Does the same happen when you use a private window (no extensions)?

@pradeepchawda
Copy link
Author

Its safari Version 16.2 (18614.3.7.1.5). Also it happens in private window.

@bashtage
Copy link
Owner

Do you see it here? https://www.statsmodels.org/stable/search.html?q=ARMAX

@pradeepchawda
Copy link
Author

No. Also it happens only in a specific repo and other repo is working fine. I checked the conf.py and version its the same.

@pradeepchawda
Copy link
Author

It does not happen in local but in gitlab pages

@macreeeeee
Copy link

I have also encountered this problem. After my testing, I found that the issue does not occur when using Sphinx version less than 6.0. Should sphinx-material consider compatibility with the new version of Sphinx🤣?

@pradeepchawda
Copy link
Author

yes, it got fixed after i downgraded to 5.3

@rgommers
Copy link

This indeed looks like a bug in this theme, in combination with a newer Sphinx version. It's visible also in the docs of this theme itself, and it shows up when using support for multiple versions of the docs:

It indeed doesn't show up for statsmodels, probably because it uses the JS file version switching rather than the conf.py method: https://bashtage.github.io/sphinx-material/devel/customization.html#using-a-javascript-file.

@rgommers
Copy link

The problematic fallback code lives here:

{% trans %}Please activate JavaScript to enable the search
. My JS foo is very weak, so not sure how Sphinx 6.x changes could affect that code.

@rgommers
Copy link

rgommers commented Mar 5, 2024

Looks like the issue is that Sphinx 5.0 and later no longer ship jQuery. Installing sphinxcontrib-jquery made the problem disappear.

@ukusormus
Copy link

ukusormus commented Sep 23, 2024

The issue can be fixed without adding a jQuery dependency by overriding your project's search page template.

Here's one possible solution with a noscript tag.
_templates/search.html:

{%- extends "basic/search.html" %}

{% block body %}
  <h1 id="search-documentation">{{ _('Search') }}</h1>
  <noscript>
    <div id="fallback" class="admonition warning">
    <p>
      {% trans %}Please activate JavaScript to enable the search
      functionality.{% endtrans %}
    </p>
    </div>
  </noscript>
  {% if search_performed %}
    <h2>{{ _('Search Results') }}</h2>
    {% if not search_results %}
      <p>{{ _('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.') }}</p>
    {% endif %}
  {% endif %}
  <div id="search-results">
  {% if search_results %}
    <ul>
    {% for href, caption, context in search_results %}
      <li><a href="{{ pathto(item.href) }}">{{ caption }}</a>
        <div class="context">{{ context|e }}</div>
      </li>
    {% endfor %}
    </ul>
  {% endif %}
  </div>
{% endblock %}

(modified from https://github.com/bashtage/sphinx-material/blob/0d31923e0fb08e85027c3e7f03d12673209872e3/sphinx_material/sphinx_material/search.html)

// that is, if you don't need the other place where jQuery is used AFAICS - version dropdown; could be replaced too I guess
https://github.com/search?q=repo%3Abashtage%2Fsphinx-material%20%24(&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants