autocomplete-textarea: Reposition popup on resize (#4718)

This commit is contained in:
Abe Jellinek 2024-10-02 03:10:22 -04:00 committed by GitHub
parent a0da169664
commit 9672571913
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,6 +23,10 @@
this.popupSelectedIndex = -1;
this._lastMoveHeight = null;
this._resizeObserver = new ResizeObserver(() => this.movePopup());
XPCOMUtils.defineLazyPreferenceGetter(
this,
"disablePopupAutohide",
@ -117,6 +121,12 @@
);
this.valueIsTyped = false;
this._resizeObserver.observe(this);
}
disconnectedCallback() {
this._resizeObserver.unobserve(this);
}
get popup() {
@ -426,6 +436,22 @@
return;
}
this.popup.closePopup();
this._lastMoveHeight = null;
}
movePopup() {
let height = this.getBoundingClientRect().height;
if (this.popupOpen && height !== this._lastMoveHeight) {
// https://searchfox.org/mozilla-central/rev/1b90936792b2c71ef931cb1b8d6baff9d825592e/toolkit/content/widgets/autocomplete-popup.js#282
this.popup.moveToAnchor(
this.popup.anchorNode,
"after_start",
0,
0,
false
);
this._lastMoveHeight = height;
}
}
showHistoryPopup() {