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

Same-page search result does not close search dropdown if search.highlight is disabled #4829

Closed
4 tasks done
jbms opened this issue Jan 5, 2023 · 7 comments
Closed
4 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@jbms
Copy link
Contributor

jbms commented Jan 5, 2023

Context

No response

Bug description

When the search.highlight feature is disabled, and a search result URL is exactly the same as the current URL and contains a #fragment, then clicking on the search result does not close the search dropdown, which is confusing.

Additionally, there is some inconsistency as to whether the search query remains in the search bar:

  • If navigation.instant is enabled, then the query always remains in the search bar after selecting a result
  • If navigation.instant is disabled and search.highlight is enabled, the query never remains in the search bar after selecting a result, since the addition of the highlight term to the query string means the page is always reloaded.
  • If navigation.instant is disabled and search.highlight is disabled, then if the result is on the same page, the query remains, otherwise the query does not remain.

Related links

N/A

Reproduction

example.zip

Steps to reproduce

  1. Open reproduction in a browser.
  2. Click on "Commands" in the right sidebar.
  3. Enter "commands" in the search bar.
  4. Select the "Commands" section in the search dropdown, and observe that the search dropdown remains open.

Browser

Chrome

Before submitting

@squidfunk
Copy link
Owner

squidfunk commented Jan 5, 2023

Thanks for reporting. However, this bug report is incomplete, as it doesn't include a reproduction and steps to reproduce. Please carefully read our new bug reporting guide and reopen the issue once you've provided all missing information.

@jbms
Copy link
Contributor Author

jbms commented Jan 5, 2023

I updated the issue to more precisely state how to reproduce the issue. I have not provided a zip file to reproduce because you can simply use this repository's own documentation, with "search.highlight" disabled.

I don't think I have permission to re-open the issue myself.

@jbms
Copy link
Contributor Author

jbms commented Jan 5, 2023

Note: A likely solution to the issue would be to add an onclick event handler to the result links that closes the search dropdown.

@squidfunk
Copy link
Owner

squidfunk commented Jan 5, 2023

Please provide a reproducible example despite it being reproducible on the docs. When you don't do the work, I have to do it, as I know have to craft a smaller example up to better debug it. When the bug is fixed, it can be tested on the whole docs, but for debugging and inspection, a good minimal example goes a long way.

See the reproduction guide how to do that, which is by the way also linked in the bug reporting guide.

@jbms
Copy link
Contributor Author

jbms commented Jan 5, 2023

I updated the issue description to include a reproduction.

@squidfunk squidfunk reopened this Jan 5, 2023
@squidfunk squidfunk added needs investigation Issue must be investigated by the maintainers bug Issue reports a bug and removed incomplete needs investigation Issue must be investigated by the maintainers labels Jan 5, 2023
@squidfunk
Copy link
Owner

Fixed in 8a812ae. The search now closes every time a search result is selected. Before, this was not handled, but rarely occurred, because it only affected same-page results for which the location didn't change, i.e. anchor already in view.


Thanks for providing the reproduction! I know that you're maintaining Sphinx Immaterial, a Sphinx-port of my work. I also understand that the new bug reporting process might feel a little boilerplatey at first, but it greatly helps us to provide bug fixes much quicker than ever before. Thanks for sticking to it!

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Jan 8, 2023
@squidfunk
Copy link
Owner

Released as part of 9.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants