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: Fix suggestion box positioning on window resize.

Akarsh Jaincaeeddd97582
diff --git a/static/third/bootstrap-typeahead/typeahead.js b/static/third/bootstrap-typeahead/typeahead.js
index 7d5d36b175f..40b6a3bf46f 100644
--- a/static/third/bootstrap-typeahead/typeahead.js
+++ b/static/third/bootstrap-typeahead/typeahead.js
@@ -93,6 +93,11 @@
* only this diff, and not the entire text, is highlighted when undoing,
* as would be ideal.
*
+ * 9. Re-render on window resize:
+ *
+ * We add a new event handler, resizeHandler, for window.on('resize', ...)
+ * that calls this.show to re-render the typeahead in the correct position.
+ *
* ============================================================ */
import {insert} from "text-field-edit";
@@ -367,6 +372,8 @@ import {get_string_diff} from "../../js/util";
.on('click', 'li', this.click.bind(this))
.on('mouseenter', 'li', this.mouseenter.bind(this))
.on('mousemove', 'li', this.mousemove.bind(this))
+
+ $(window).on('resize', this.resizeHandler.bind(this));
}
, unlisten: function () {
@@ -387,6 +394,12 @@ import {get_string_diff} from "../../js/util";
return isSupported
}
+ , resizeHandler: function() {
+ if(this.shown) {
+ this.show();
+ }
+ }
+
, move: function (e) {
if (!this.shown) return
const pseudo_keycode = get_pseudo_keycode(e);