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 compose topic typeahead partially hidden.

Aman Agrawal240c870815d8
diff --git a/web/src/bootstrap_typeahead.ts b/web/src/bootstrap_typeahead.ts
index 0038e651420..5209340889f 100644
--- a/web/src/bootstrap_typeahead.ts
+++ b/web/src/bootstrap_typeahead.ts
@@ -439,27 +439,27 @@ 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,
- onMount: () => {
+ onMount: (instance) => {
// The container has `display: none` as a default style.
// We make sure to display it. For tippy elements, this
// must happen after we insert the typeahead into the DOM.
this.$container.show();
+ // Reasons to update the position of the typeahead here:
+ // * Simplebar causes the height of the typeahead to
+ // change, which can cause the typeahead to go off
+ // screen like in compose topic typeahead.
+ // * Since we use an offset which can partially hide
+ // typeahead at certain caret positions in textarea
+ // input, we need to push it back into view once we
+ // have rendered the typeahead.
+ requestAnimationFrame(() => {
+ // This detects any overflows by default and adjusts
+ // the placement of typeahead.
+ void instance.popperInstance?.update();
+ });
},
});
}