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: Ignore blurs that change focus within the `parentElement`.

evykassirer63c424c5bc7e
diff --git a/web/third/bootstrap-typeahead/typeahead.js b/web/third/bootstrap-typeahead/typeahead.js
index 71b77d2debf..ad10dcce5ef 100644
--- a/web/third/bootstrap-typeahead/typeahead.js
+++ b/web/third/bootstrap-typeahead/typeahead.js
@@ -125,6 +125,11 @@
* functionality. The `tabIsEnter` option (default true) lets this be
* turned off so that tab only does one thing while focus is in the
* typeahead -- move focus to the next element.
+ *
+ * 14. Don't act on blurs that change focus within the `parentElement`:
+ *
+ * This allows us to have things like a close button, and be able
+ * to move focus there without the typeahead closing.
* ============================================================ */
import {insert} from "text-field-edit";
@@ -539,6 +544,11 @@ import {get_string_diff} from "../../src/util";
}
, blur: function (e) {
+ // Blurs that move focus to elsewhere within the parent element shouldn't
+ // hide the typeahead.
+ if ($(e.relatedTarget).parents(this.options.parentElement).length > 0) {
+ return;
+ }
var that = this
setTimeout(function () {
if (!that.$container.is(':hover')) {