Skip to content

Commit

Permalink
Improved #254
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Dec 22, 2017
1 parent 3beeecf commit 4b75494
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/autocomplete/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class AutoComplete extends Component {
else {
if(query.length >= this.props.minLength) {
this.timeout = setTimeout(() => {
this.search(event, query);
this.search(event, query, 'input');
}, this.props.delay);
}
else {
Expand All @@ -161,9 +161,14 @@ export class AutoComplete extends Component {
}
}

search(event, query) {
search(event, query, source) {
//allow empty string but not undefined or null
if(query === undefined || query === null ) {
if (query === undefined || query === null) {
return;
}

//do not search blank values on input change
if (source === 'input' && query.trim().length === 0) {
return;
}

Expand Down Expand Up @@ -258,9 +263,9 @@ export class AutoComplete extends Component {
}

if(this.props.dropdownMode === 'blank')
this.search(event, '');
this.search(event, '', 'dropdown');
else if(this.props.dropdownMode === 'current')
this.search(event, this.inputEl.value);
this.search(event, this.inputEl.value, 'dropdown');

if(this.props.onDropdownClick) {
this.props.onDropdownClick({
Expand Down

0 comments on commit 4b75494

Please sign in to comment.