From 196f4e92a3c4e722cdf14379eba3190b1aafdfaa Mon Sep 17 00:00:00 2001 From: userAdityaa Date: Sat, 22 Feb 2025 02:55:22 +0530 Subject: [PATCH] resize_observer: Prevent loop using requestAnimationFrame. This commit solves the issue where the ResizeObserver loop completes with undelivered notifications. By using requestAnimationFrame, the resize event is deferred until after the paint cycle, preventing an infinite loop caused by consecutive resize triggers before repaint. --- web/src/compose_setup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js index e2fbe81423..0a13374862 100644 --- a/web/src/compose_setup.js +++ b/web/src/compose_setup.js @@ -108,7 +108,11 @@ export function initialize() { // Updates compose max-height and scroll to bottom button position when // there is a change in compose height like when a compose banner is displayed. - const update_compose_max_height = new ResizeObserver(resize.reset_compose_message_max_height); + const update_compose_max_height = new ResizeObserver((_entries) => { + requestAnimationFrame(() => { + resize.reset_compose_message_max_height(); + }); + }); update_compose_max_height.observe(document.querySelector("#compose")); function get_input_info(event) {