typeahead: Fix suggestion box positioning on window resize.

The suggestion box was not being repositioned correctly when the window
was resized. This commit adds a resizeHandler() function to handle
window resizing properly and reposition the suggestion box to its
current position.

Fixes: #23681.
This commit is contained in:
Akarsh Jain 2022-12-11 18:24:41 +05:30 committed by Tim Abbott
parent 256e9651b6
commit caeeddd975
1 changed files with 13 additions and 0 deletions

View File

@ -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);