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 text not removed - when click the result which already an active url #13

Closed
Nilanth opened this issue Jun 15, 2020 · 8 comments
Closed
Assignees
Labels
bug Something isn't working on hold

Comments

@Nilanth
Copy link

Nilanth commented Jun 15, 2020

Hi,
The search text in the search bar is not removed once we click the search result.

@lelouch77 lelouch77 self-assigned this Jun 15, 2020
@lelouch77 lelouch77 added the bug Something isn't working label Jun 15, 2020
@lelouch77
Copy link
Collaborator

Thanks for reporting @Nilanth, I will take a look 👍

@lelouch77 lelouch77 changed the title Search text not removed Search text not removed - when click the result which already an active url Jul 4, 2020
@lelouch77
Copy link
Collaborator

This issue happens only when you select a result which is already an active URL..

@Nilanth
Copy link
Author

Nilanth commented Jul 4, 2020

No, it occurs on all pages!
You can check in this demo itself https://lelouch77.github.io/docusaurus-lunr-search-demo/

@mattcorner
Copy link

When moving from landing page to documentation the search is cleared. However @Nilanth is right that once in the documentation, the search is never cleared.

@lelouch77
Copy link
Collaborator

Thats the old documentation link.. try this https://lelouch77.github.io/docusaurus-lunr-search-multilang @Nilanth @mattcorner

@mattcorner
Copy link

Its a bit inconsistent. Sometimes it does remove clear the search, but a lot of the time it doesn't. Here it is not clearing on the new demo @lelouch77

This only occurs for doc to doc navigation

docs-lunr-search-not-clearing

@felipeog
Copy link

felipeog commented Jan 24, 2021

Hi,
The search text in the search bar is not removed once we click the search result.

On /src/theme/SearchBar/index.js, I added _input.setVal('') and _event.target.blur() on the handleSelected function (line 25):

const initAlgolia = (searchDocs, searchIndex, DocSearch) => {
  new DocSearch({
    searchDocs,
    searchIndex,
    inputSelector: "#search_input_react",
    handleSelected: (_input, _event, suggestion) => {
      const url = baseUrl + suggestion.url;
      const a = document.createElement("a");
      a.href = url;

      _input.setVal(''); // clear value
      _event.target.blur(); // remove focus

      history.push(url);
    }
  });
};

So the input is cleared and its focus is removed when a result is clicked. Hope it helps!

@praveenn77
Copy link
Owner

fixed in new version 3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working on hold
Projects
None yet
Development

No branches or pull requests

5 participants