minLength: 0 should be implemented
See original GitHub issueCurrently minLength: 0
behaves like minLength: 1
. In some applications it is quite useful to be able to fetch and display all of the possibilities right away because the number is small enough or they are cleverly sorted by likelihood of relevance. This can eliminate the need to use a different component for an almost identical use case.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (5 by maintainers)
Top Results From Across the Web
HTML attribute: minlength - HTML: HyperText Markup Language
The minlength attribute defines the minimum number of characters (as UTF-16 code units) the user ... This must be an integer value 0...
Read more >Why doesn't input minlength check work with initial value?
This is by design. The minlength attribute only validates a field once it has been edited by the user. It doesn't validate the...
Read more >How to Set a Minlength Validation in HTML5 - W3docs
In this snippet, find out what alternative attributes to minlength can be used to set a minlength validation in HTML5. Read our snippet...
Read more >How to fix: Attribute “minlength” is only allowed when the input ...
This must be an integer value 0 or higher. If no minlength is specified, or an invalid value is specified, the input has...
Read more >HTML input minlength Attribute - W3Schools
The minlength attribute specifies the minimum number of characters required in an input field. Note: The minlength attribute can be used with input...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, @ericgio, thank you for your fast response. This may be the intended behavior, but it doesn’t seem correct. If the user can specify a
minLength
of 0 (which is valid according to the docs), then theonSearch
should fire for empty queries.Consider my use-case. I have a dataset of 1000+ entries. When the user has no query, we display a short list of likely relevant choices. This means if the user types a query, and then removes it, we would need to once again display the likely relevant choices.
Sure there is. You can use
onInputChange
to get the current input value.onSearch
is just a debounced callback being passed toonInputChange
anyway.Note that AsyncTypeahead is just an HOC that adds some simple debouncing and a basic cache to the main Typeahead component. It’s provided with the library for convenience and to handle most simple async use cases. If it doesn’t meet your needs you can easily write your own HOC that handles things exactly as you’d like them to.