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.
This commit is contained in:
userAdityaa
2025-02-22 02:55:22 +05:30
committed by Tim Abbott
parent f6bb990b91
commit 196f4e92a3

View File

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