This commit is contained in:
Timothy Jaeryang Baek
2026-05-09 16:37:19 +09:00
parent 413dcae8a2
commit 7d3efb8513
2 changed files with 33 additions and 1 deletions
+23
View File
@@ -1463,6 +1463,29 @@
top: messagesContainerElement.scrollHeight,
behavior
});
// content-visibility: auto causes the initial scrollHeight to be based on
// estimated sizes (contain-intrinsic-size). After we scroll, previously
// off-screen messages become visible and the browser resolves their actual
// heights, which shifts scrollHeight. Re-layouts can cascade across frames
// (new sizes reveal more content, triggering further size resolution), so
// we re-scroll across two animation frames to land at the true bottom.
requestAnimationFrame(() => {
if (messagesContainerElement) {
messagesContainerElement.scrollTo({
top: messagesContainerElement.scrollHeight,
behavior
});
requestAnimationFrame(() => {
if (messagesContainerElement) {
messagesContainerElement.scrollTo({
top: messagesContainerElement.scrollHeight,
behavior
});
}
});
}
});
}
};
+10 -1
View File
@@ -140,7 +140,16 @@
const scrollToBottom = () => {
const element = document.getElementById('messages-container');
element.scrollTop = element.scrollHeight;
if (element) {
element.scrollTop = element.scrollHeight;
// Follow-up scroll to account for content-visibility: auto re-layouts
requestAnimationFrame(() => {
if (element) {
element.scrollTop = element.scrollHeight;
}
});
}
};
export const scrollToTop = async () => {