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

Fetch on focus #121

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

elalemanyo
Copy link

This pr is trying to fix issue #110. The idea is to fetch data on focus if minLength is 0.
The proposed solution in the issue was not working if the user select one suggestion doing click.

@netlify
Copy link

netlify bot commented Oct 20, 2022

Deploy Preview for stimulus-autocomplete canceled.

Name Link
🔨 Latest commit 4588aa1
🔍 Latest deploy log https://app.netlify.com/sites/stimulus-autocomplete/deploys/6356332dbec66f0008ad1051

@ACPK
Copy link

ACPK commented Mar 1, 2023

@elalemanyo I get a blank

    because my resultsShown is based on HTML rather than the amount of actual results. If I may ask, how do you handle this. For example,

    In other words, how do you handle searches where @results.present? equals false?

    @results = product.search(params["q"])

    The code below generates an error because autocomplete.js cannot find the box when there is an HTML response but @results.present? is false

     <% if @results %>
        <ul data-autocomplete-target="results"  class="list-none absolute z-10 mt-3 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" id="options" role="listbox">
        </ul>
       <% end %>
    

    @elalemanyo
    Copy link
    Author

    @elalemanyo I get a blank

    because my resultsShown is based on HTML rather than the amount of actual results. If I may ask, how do you handle this. For example,
    In other words, how do you handle searches where @results.present? equals false?

    @results = product.search(params["q"])

    The code below generates an error because autocomplete.js cannot find the box when there is an HTML response but @results.present? is false

     <% if @results %>
        <ul data-autocomplete-target="results"  class="list-none absolute z-10 mt-3 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" id="options" role="listbox">
        </ul>
       <% end %>
    

    I have to admit that I don't think I understand the question 😬
    But the idea would be not to answer an empty result. What we do is that if the user has not yet entered any text what the search api responds is a few random suggestions. Anyway, this is more of an implementation issue and has little to do with functionality, IMO. Let me know if I can help you 🙂.

    @elalemanyo
    Copy link
    Author

    @afcapel Is there any possibility to merge this? We have been using it for some time now and we think it works very well 🙂
    Thanks

    @arrowcircle
    Copy link

    Any updates on merging this?

    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

    Successfully merging this pull request may close these issues.

    3 participants