Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-birds-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes the message list shifting when typing in the fully expanded message composer
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,35 @@ export const useKeepAtBottom = (isAtBottom: MutableRefObject<boolean | null>) =>
const keepAtBottomRef = useSafeRefCallback(
useCallback(
(node: HTMLDivElement) => {
const sendToBottom = () => {
if (isAtBottom.current && handleRef.current) {
handleRef.current();
}
};
const listWrapper = node.firstChild;
const observer = new ResizeObserver(() => {
if (isAtBottom.current) {
if (handleRef.current) {
handleRef.current();
}
}
sendToBottom();
});

observer.observe(node);
if (listWrapper instanceof HTMLElement) {
observer.observe(listWrapper);
}

const sendToBottomEvent = (e: Event) => {
if (!(e.target instanceof HTMLElement)) return;
if (!e.target.closest('.rc-message-box')) return;
sendToBottom();
};

// Workaround for height hack in useAutoGrow
// node.style.height = '0';
// node.style.height = `${node.scrollHeight}px`;
window.addEventListener('input', sendToBottomEvent);

return () => {
observer.disconnect();
window.removeEventListener('input', sendToBottomEvent);
};
},
[isAtBottom],
Expand Down
Loading