afcapel / stimulus-autocomplete

Stimulus autocomplete component
MIT License
478 stars 61 forks source link

Add ability to use local options #133

Open krzyzak opened 1 year ago

krzyzak commented 1 year ago

Hey!

First of all, thank you for this component, it's very useful in my project! As a follow-up to #116, I added possibility to pass options Array, which then can be used in the component.

It also exposes 2 methods:

It allows you to pass not only a plain array, but also an array of objects, with different name and values.

I didn't update the docs, nor did I provide any examples, because first I wanted to get your initial feedback on that.

netlify[bot] commented 1 year ago

Deploy Preview for stimulus-autocomplete canceled.

Name Link
Latest commit 7bc62b361c38edcd5b2a123e95018ef30d407347
Latest deploy log https://app.netlify.com/sites/stimulus-autocomplete/deploys/6400b091e2730b0008500536
ajhepple commented 1 week ago

This is just the feature I wanted, thanks, but the proposed changes broke my remotely fetched options. Thankfully it was a simple fix, to add parentheses around the use of the ternary operator;

const html = await (this.hasOptionsValue ? this.fetchLocalOptions(query) : ...

Otherwise the wait doesn't apply to the remote fetch!