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 typeahead overflowing out of window.

Aman Agrawal6c500e9a6e86
diff --git a/web/src/bootstrap_typeahead.ts b/web/src/bootstrap_typeahead.ts
index 3f408f3445f..b5e1d17e4d6 100644
--- a/web/src/bootstrap_typeahead.ts
+++ b/web/src/bootstrap_typeahead.ts
@@ -455,6 +455,19 @@ export class Typeahead<ItemType extends string | object> {
}
return [0, gap];
},
+ onShow(instance) {
+ if (input_element.type === "textarea") {
+ // Since we use an offset which can partially hide typeahead
+ // at certain caret positions, we need to push it back into
+ // view once we have rendered the typeahead. The movement
+ // feels like an animation to the user.
+ setTimeout(() => {
+ // This detects any overflows by default and adjusts
+ // the placement of typeahead.
+ void instance.popperInstance?.update();
+ }, 0);
+ }
+ },
// We have event handlers to hide the typeahead, so we
// don't want tippy to hide it for us.
hideOnClick: false,