meilisearch / docs-searchbar.js

Front-end search bar for documentation with Meilisearch
https://www.meilisearch.com/
MIT License
169 stars 30 forks source link

Auto search when search input has content and actived #668

Closed imvkmark closed 1 year ago

imvkmark commented 2 years ago

When there is content in the search box, click the search box, the search box is activated, and the search result window is not automatically opened

Expected: When the search box has content and is activated

  1. All texts are in the selected state, which is convenient to directly enter new content for searching
  2. Open the search result page to display the search content, which is convenient to adjust the search conditions again

image site: https://wulicode.com

bidoubiwa commented 2 years ago

Hey @imvkmark it seems that there is a bug with your docs-searchbar. Can you provide the code initializing it?

imvkmark commented 2 years ago

@bidoubiwa , Thank for your help. There has 2 parts in my blog.

at main.js, the hostUrl can opened in browser

docsSearchBar({
    hostUrl: 'https://platform.jkfxpt.com:7770',
    apiKey: 'f1f95fdb28d7eda1cea1b47d1ae162802954fca8762c1f05dfd19cb403ba1d9b',
    indexUid: 'wulicode-scraper',
    inputSelector: '#search-bar-input',
    debug: false, // Set debug to true if you want to inspect the dropdown
})

at html

<div className="columns meilisearch">
    <div class="column column-left is-4-tablet is-4-desktop is-4-widescreen  order-1">
        <div class=" card widget">
            <input type="search" id="search-bar-input" placeholder="search use meilisearch"/>
        </div>
    </div>
</div>
bidoubiwa commented 2 years ago

what happens if you add docsSearchBar in a script tag inside your HTML file ?

<script>
docsSearchBar({
    hostUrl: 'https://platform.jkfxpt.com:7770',
    apiKey: 'f1f95fdb28d7eda1cea1b47d1ae162802954fca8762c1f05dfd19cb403ba1d9b',
    indexUid: 'wulicode-scraper',
    inputSelector: '#search-bar-input',
    debug: false, // Set debug to true if you want to inspect the dropdown
})
</script>
imvkmark commented 2 years ago

I'm use hexo for static site, so i can't add script to jsx file.

bidoubiwa commented 2 years ago

From what I see in the logs, docsSearchbar is not imported in the HTML file. Maybe the module was not imported correctly in your code

imvkmark commented 2 years ago

Because of the slow access of cdn in China, I download the js file to my source directory. so you may cannot find access log from network panel. image

bidoubiwa commented 2 years ago

if you console.log docsSearchBar does it appear in your browser logs?

imvkmark commented 2 years ago

if you console.log docsSearchBar does it appear in your browser logs?

image

Yes

bidoubiwa commented 2 years ago

@imvkmark okey I just understood the issue. You are right, because of the Chinese CDN it was not working at all on my end (or it could work but I should have waited longer).

So the improvement you are requiring: If there is text in the input and focus is put on the input, the results component should automatically open ?

imvkmark commented 2 years ago

Yes, That's what i mean. like notion's search bar.

bidoubiwa commented 1 year ago

We welcome user to use the meilisearch-docsearch of tauri that is a better version of this project. For this reason, we deprecate this repository in favor of theirs.