fix for heading space in search box (#4868)

This commit is contained in:
gabryon99 2020-12-29 15:14:39 +01:00
parent 4bb913884a
commit 9bd7d2dd3c
3 changed files with 6 additions and 9 deletions

View file

@ -158,12 +158,9 @@
if (typeof(query) != 'undefined' && query !== null) {
this.query = query;
} else {
this.query = this.$element.val() || this.$element.text() || '';
this.query = this.$element.val().trim() || this.$element.text().trim() || '';
}
// trim spaces
this.query.trim();
if (this.query.length < this.options.minLength && !this.options.showHintOnFocus) {
return this.shown ? this.hide() : this;
}
@ -420,8 +417,8 @@
// prevent spacing at the start
let currentValue = this.$element.val() || this.$element.text();
currentValue = currentValue.trim();
if (e.keyCode == 32 && currentValue === "") {
if (e.keyCode == 32 && currentValue === "" || e.keyCode === 32 && e.target.selectionStart == 0) {
e.preventDefault();
return;
}
@ -465,13 +462,13 @@
if (!this.shown) return;
this.select();
break;
case 27: // escape
if (!this.shown) return;
this.hide();
break;
}
},