Fix AI chat scroll behavior (#15686)

This commit is contained in:
Abdul Rahman
2025-11-14 05:50:25 +05:30
committed by GitHub
parent 9d43058e50
commit bff079d3b5
8 changed files with 67 additions and 27 deletions
@@ -0,0 +1,23 @@
import { AI_CHAT_SCROLL_WRAPPER_ID } from '@/ai/constants/AiChatScrollWrapperId';
import { useScrollWrapperHTMLElement } from '@/ui/utilities/scroll/hooks/useScrollWrapperHTMLElement';
import { isDefined } from 'twenty-shared/utils';
export const useAgentChatScrollToBottom = () => {
const { getScrollWrapperElement } = useScrollWrapperHTMLElement(
AI_CHAT_SCROLL_WRAPPER_ID,
);
const scrollToBottom = () => {
const { scrollWrapperElement } = getScrollWrapperElement();
if (!isDefined(scrollWrapperElement)) {
return;
}
scrollWrapperElement.scrollTo({
top: scrollWrapperElement.scrollHeight,
behavior: 'smooth',
});
};
return { scrollToBottom };
};