Skip to content

Respect min-length-value option#138

Closed
Simonpedro wants to merge 1 commit intoafcapel:mainfrom
Simonpedro:respect-min-length-value
Closed

Respect min-length-value option#138
Simonpedro wants to merge 1 commit intoafcapel:mainfrom
Simonpedro:respect-min-length-value

Conversation

@Simonpedro
Copy link
Copy Markdown

@Simonpedro Simonpedro commented Jun 28, 2023

When the min length value is set to 0, the autocomplete will not fetch the data from the server. This is a problem when a consumer wants to also show something when the input is empty.

For example, it would unblock the following use case:

<input
  name="search"
  data-autocomplete-target="input"
  data-autocomplete-url-value="/search?q={q}"
  data-autocomplete-min-length-value="0"
  data-action="click->autocomplete#onInputChange"
/>

in which some results are shown as soon as the input is focused.

It's a simple way to address the "fetch on focus" issue and an alternative to "fetch on focus" PR.

When the min length value is set to 0, the autocomplete will not fetch
the data from the server. This is a problem when a consumer wants to
also show something when the input is empty.

For example, it would unblock the following use case:

```html
<input
  name="search"
  data-autocomplete-target="input"
  data-autocomplete-url-value="/search?q={q}"
  data-autocomplete-min-length-value="0"
  data-action="focusin->autocomplete#onInputChange"
/>
```

in which some results are shown as soon as the input is focused.
@netlify
Copy link
Copy Markdown

netlify bot commented Jun 28, 2023

Deploy Preview for stimulus-autocomplete canceled.

Name Link
🔨 Latest commit 9628feb
🔍 Latest deploy log https://app.netlify.com/sites/stimulus-autocomplete/deploys/649b93663a1b200007f719f7

@Simonpedro
Copy link
Copy Markdown
Author

Seems it didn't gain traction.

@Simonpedro Simonpedro closed this Jul 7, 2023
@arrowcircle
Copy link
Copy Markdown

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.

2 participants