Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #76 from ostermanj/master
Browse files Browse the repository at this point in the history
Adds noResults property to prevent onChange event from firing when k…
  • Loading branch information
Mobius1 committed Nov 6, 2018
2 parents b995672 + e04c2b0 commit 976e67f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/selectr.js
Expand Up @@ -717,7 +717,7 @@

if (e.which === 13) {

if (this.config.taggable && this.input.value.length > 0) {
if ( this.noResults || (this.config.taggable && this.input.value.length > 0) ) {
return false;
}

Expand Down Expand Up @@ -1960,12 +1960,14 @@
// Append results
if ( !f.childElementCount ) {
if ( !this.config.taggable ) {
this.noResults = true;
this.setMessage( this.config.messages.noResults );
}
} else {
// Highlight top result (@binary-koan #26)
var prevEl = this.items[this.navIndex];
var firstEl = f.querySelector(".selectr-option:not(.excluded)");
this.noResults = false;

util.removeClass( prevEl, "active" );
this.navIndex = firstEl.idx;
Expand Down

0 comments on commit 976e67f

Please sign in to comment.