Open elalemanyo opened 1 year ago
Name | Link |
---|---|
Latest commit | 4588aa1a625ce54a60bcb7c79d4385f73338cf3b |
Latest deploy log | https://app.netlify.com/sites/stimulus-autocomplete/deploys/6356332dbec66f0008ad1051 |
@elalemanyo I get a blank
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 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 🙂.
@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
Any updates on merging this?
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.