remove colors / suggestions on form hide

This commit is contained in:
Cade Scroggins
2018-12-16 14:29:36 -08:00
parent 06cdd7f388
commit 64756c5842
+7 -2
View File
@@ -796,6 +796,7 @@
class Suggester { class Suggester {
constructor(options) { constructor(options) {
this._el = $.el('#search-suggestions'); this._el = $.el('#search-suggestions');
this._enabled = options.enabled;
this._influencers = options.influencers; this._influencers = options.influencers;
this._limit = options.limit; this._limit = options.limit;
this._suggestionEls = []; this._suggestionEls = [];
@@ -821,6 +822,7 @@
} }
suggest(input) { suggest(input) {
if (!this._enabled) return;
input = input.trim(); input = input.trim();
if (input === '') this._clearSuggestions(); if (input === '') this._clearSuggestions();
@@ -1067,6 +1069,8 @@
$.bodyClassRemove('form'); $.bodyClassRemove('form');
this._inputEl.value = ''; this._inputEl.value = '';
this._inputElVal = ''; this._inputElVal = '';
this._suggester.suggest('');
this._setBackgroundFromQuery('');
} }
show() { show() {
@@ -1084,11 +1088,11 @@
const isHelp = newQuery === '?'; const isHelp = newQuery === '?';
const { isKey } = this._parseQuery(newQuery); const { isKey } = this._parseQuery(newQuery);
this._inputElVal = newQuery; this._inputElVal = newQuery;
this._suggester.suggest(newQuery);
this._setBackgroundFromQuery(newQuery); this._setBackgroundFromQuery(newQuery);
if (!newQuery || isHelp) this.hide(); if (!newQuery || isHelp) this.hide();
if (isHelp) this._toggleHelp(); if (isHelp) this._toggleHelp();
if (this._instantRedirect && isKey) this._submitWithValue(newQuery); if (this._instantRedirect && isKey) this._submitWithValue(newQuery);
if (this._suggester) this._suggester.suggest(newQuery);
} }
_handleKeydown(e) { _handleKeydown(e) {
@@ -1176,6 +1180,7 @@
}); });
const suggester = new Suggester({ const suggester = new Suggester({
enabled: CONFIG.suggestions,
influencers, influencers,
limit: CONFIG.suggestionsLimit, limit: CONFIG.suggestionsLimit,
}); });
@@ -1190,7 +1195,7 @@
instantRedirect: CONFIG.instantRedirect, instantRedirect: CONFIG.instantRedirect,
newTab: CONFIG.newTab, newTab: CONFIG.newTab,
parseQuery: queryParser.parse, parseQuery: queryParser.parse,
suggester: CONFIG.suggestions ? suggester : null, suggester,
toggleHelp: help.toggle, toggleHelp: help.toggle,
}); });