diff --git a/net/web/src/session/conversation/Conversation.jsx b/net/web/src/session/conversation/Conversation.jsx index c39786e7..22941ed0 100644 --- a/net/web/src/session/conversation/Conversation.jsx +++ b/net/web/src/session/conversation/Conversation.jsx @@ -1,4 +1,4 @@ -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { ConversationWrapper, StatusError } from './Conversation.styled'; import { ExclamationCircleOutlined, SettingOutlined, CloseOutlined } from '@ant-design/icons'; import { useConversation } from './useConversation.hook'; @@ -9,6 +9,9 @@ import { List, Spin, Tooltip } from 'antd'; export function Conversation({ closeConversation, openDetails, cardId, channelId }) { + const height = useRef(0); + const latch = useRef(null); + const { state, actions } = useConversation(cardId, channelId); const thread = useRef(null); @@ -16,6 +19,21 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId return () } + // an unfortunate cludge for the mobile browser + // scrollTop not updated without a scroll event + useEffect(() => { + latch.current = setInterval(() => { + if (thread.current && height.current !== thread.current.scrollHeight) { + height.current = thread.current.scrollHeight; + if (thread.current.scrollTop === 0) { + thread.current.scrollTo({ top: -16, left: 0, behavior: 'smooth' }); + thread.current.scrollTo({ top: 0, left: 0, behavior: 'smooth' }); + } + } + }, 1000); + return () => clearInterval(latch.current); + }, []); + const scrollThread = (e) => { const content = thread.current?.scrollHeight; const frame = thread.current?.clientHeight; @@ -64,7 +82,7 @@ export function Conversation({ closeConversation, openDetails, cardId, channelId )} { state.topics.length !== 0 && ( + size="large" gutter="0" renderItem={topicRenderer} /> )} { state.loadingInit && (