mirror of
https://github.com/danog/react-datalist-input.git
synced 2025-01-22 13:52:41 +01:00
better ux
This commit is contained in:
parent
9f677a631e
commit
bfaf980d4a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-datalist-input",
|
||||
"version": "1.1.33",
|
||||
"version": "1.1.34",
|
||||
"description": "This package provides a react component as follows: an input field with a drop down menu to pick a possible option based on the current input.",
|
||||
"main": "./lib/DataListInput.js",
|
||||
"license": "MIT",
|
||||
|
@ -63,9 +63,15 @@ class DataListInput extends React.Component {
|
||||
|
||||
onClickInput = () => {
|
||||
const { currentInput, visible, lastValidItem } = this.state;
|
||||
const { requiredInputLength, dropDownLength, items, match, clearInputOnSelect } = this.props;
|
||||
const { requiredInputLength, dropDownLength, items, match, clearInputOnSelect, initialValue } = this.props;
|
||||
const reachedRequiredLength = currentInput.length >= requiredInputLength;
|
||||
|
||||
// if user clicks on input field with initialValue,
|
||||
// the user most likely wants to clear the input field
|
||||
if ( initialValue && currentInput === initialValue ) {
|
||||
this.setState( { currentInput: '' } );
|
||||
}
|
||||
|
||||
if ( reachedRequiredLength && !visible ) {
|
||||
|
||||
const matchingItems = items.filter( ( item ) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user