afcapel / stimulus-autocomplete

Stimulus autocomplete component
MIT License
478 stars 61 forks source link

Close if empty html #124

Open elalemanyo opened 1 year ago

elalemanyo commented 1 year ago

I think it makes more sense to open the results only when there are results. In my case, this resulted in some style inconsistencies.

shot2022-11-16 at 16 37 59@2x

netlify[bot] commented 1 year ago

Deploy Preview for stimulus-autocomplete ready!

Name Link
Latest commit b3e3f3d33cd9c7b109a46341c089791cf35aa9e0
Latest deploy log https://app.netlify.com/sites/stimulus-autocomplete/deploys/63eaa6f44d08750008fcd686
Deploy Preview https://deploy-preview-124--stimulus-autocomplete.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

elalemanyo commented 1 year ago

@ACPK did you check the example? https://github.com/afcapel/stimulus-autocomplete/pull/124/files

ACPK commented 1 year ago

@elalemanyo Yes but the Rails example should be updated to reflect the change.

I found that HTML (from this PR) returns true due to a code comment with the name of the controller.

Doesn't work: render layout: false if !@results.present?

It could be resolved in Rails 7 by adding the following code to the controller.

Works: head 200, content_type: "text/html" if !@results.present?

elalemanyo commented 1 year ago

@afcapel Is there any possibility to merge this? We believe it could be of interest to other users. Thanks