typeahead: Fix typeahead overflowing out of window.

When the caret in textarea is around the right end of the screen,
typeahead can overflow the window. To fix it, we use tippy's
mechanism to keep the tooltip inside the visible boundary.
This commit is contained in:
Aman Agrawal 2024-07-27 10:09:22 +00:00 committed by Tim Abbott
parent c88e1291f0
commit 6c500e9a6e
1 changed files with 13 additions and 0 deletions

View File

@ -455,6 +455,19 @@ export class Typeahead<ItemType extends string | object> {
} }
return [0, gap]; 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 // We have event handlers to hide the typeahead, so we
// don't want tippy to hide it for us. // don't want tippy to hide it for us.
hideOnClick: false, hideOnClick: false,