only schedule one resize callback per frame

This commit is contained in:
Bruno Windels 2021-11-05 17:48:08 +01:00
parent b22437840d
commit c671596c6f

View file

@ -25,6 +25,7 @@ export class MessageComposer extends TemplateView {
this._input = null; this._input = null;
this._attachmentPopup = null; this._attachmentPopup = null;
this._focusInput = null; this._focusInput = null;
this._rafResizeHandle = undefined;
} }
render(t, vm) { render(t, vm) {
@ -112,10 +113,14 @@ export class MessageComposer extends TemplateView {
} }
_adjustHeight() { _adjustHeight() {
window.requestAnimationFrame(() => { if (this._rafResizeHandle) {
return;
}
this._rafResizeHandle = window.requestAnimationFrame(() => {
this._input.style.height = "auto"; this._input.style.height = "auto";
const scrollHeight = this._input.scrollHeight; const scrollHeight = this._input.scrollHeight;
this._input.style.height = `${scrollHeight}px`; this._input.style.height = `${scrollHeight}px`;
this._rafResizeHandle = undefined;
}); });
} }