Skip to content

Commit 71011de

Browse files
committed
Fix resize when content of the templates section updates
1 parent 9182331 commit 71011de

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/tasks/src/hooks/useScrollableHeight.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,24 @@ export function useScrollableHeight(
4545
}
4646
});
4747

48+
// Observe content child so the layout recalculates when
49+
// the content is replaced (e.g. loading state -> form).
50+
function observeContent() {
51+
if (scroll?.firstElementChild) {
52+
observer.observe(scroll.firstElementChild);
53+
}
54+
}
55+
4856
observer.observe(host);
4957
observer.observe(scroll);
58+
observeContent();
59+
60+
const mutations = new MutationObserver(observeContent);
61+
mutations.observe(scroll, { childList: true });
5062

51-
return () => observer.disconnect();
63+
return () => {
64+
observer.disconnect();
65+
mutations.disconnect();
66+
};
5267
}, [hostRef, scrollRef]);
5368
}

0 commit comments

Comments
 (0)