Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typeahead: Refactor to avoid no-case-declarations issue.

evykassirer331efb0defeb
diff --git a/web/third/bootstrap-typeahead/typeahead.js b/web/third/bootstrap-typeahead/typeahead.js
index 34de4ddc9b2..2de6f2517d1 100644
--- a/web/third/bootstrap-typeahead/typeahead.js
+++ b/web/third/bootstrap-typeahead/typeahead.js
@@ -554,7 +554,13 @@ import {get_string_diff} from "../../src/util";
) {
return;
}
- var hideOnEmpty = false;
+ if (this.options.openInputFieldOnKeyUp !== null && !this.shown) {
+ // If the typeahead isn't shown yet, the `lookup` call will open it.
+ // Here we make a callback to the input field before we open the
+ // lookahead in case it needs to make UI changes first (e.g. widening
+ // the search bar).
+ this.options.openInputFieldOnKeyUp();
+ }
// backspace
if (
e.keyCode === 8 &&
@@ -562,16 +568,10 @@ import {get_string_diff} from "../../src/util";
// to display typeahead after hitting backspace to clear the input.
(typeof this.options.hideOnEmpty === undefined || this.options.hideOnEmpty)
) {
- hideOnEmpty = true;
- }
- if (this.options.openInputFieldOnKeyUp !== null && !this.shown) {
- // If the typeahead isn't shown yet, the `lookup` call will open it.
- // Here we make a callback to the input field before we open the
- // lookahead in case it needs to make UI changes first (e.g. widening
- // the search bar).
- this.options.openInputFieldOnKeyUp();
+ this.lookup(true);
+ } else {
+ this.lookup(false);
}
- this.lookup(hideOnEmpty);
}
this.maybeStopAdvance(e);