Fix AI chat scroll behavior (#15686)
This commit is contained in:
@@ -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 };
|
||||
};
|
||||
Reference in New Issue
Block a user