@@ -41,7 +41,6 @@ const ReadMoreButton = styled.button`
4141export function MessageBubble ( { children } : { children : ReactNode } ) {
4242 const [ expanded , setExpanded ] = useState ( false ) ;
4343 const [ showReadMore , setShowReadMore ] = useState ( false ) ;
44- const hiddenHeight = useRef < number > ( 0 ) ;
4544 const msgBubbleRef = useRef < HTMLDivElement > ( null ) ;
4645
4746 const messagesContainerRef = useMessagesContainerRef ( ) ;
@@ -80,13 +79,11 @@ export function MessageBubble({ children }: { children: ReactNode }) {
8079
8180 const msgContainerBefore = messagesContainerRef . current ;
8281
83- if ( ! msgContainerBefore ) {
84- return ;
85- }
86-
87- const { scrollTop : scrollTopBefore , scrollHeight : scrollHeightBefore } = msgContainerBefore ;
82+ if ( msgContainerBefore ) {
83+ const { scrollTop : scrollTopBefore , scrollHeight : scrollHeightBefore } = msgContainerBefore ;
8884
89- scrollBefore . current = { scrollTop : scrollTopBefore , scrollHeight : scrollHeightBefore } ;
85+ scrollBefore . current = { scrollTop : scrollTopBefore , scrollHeight : scrollHeightBefore } ;
86+ }
9087
9188 // we cannot "show less", only show more
9289 setExpanded ( true ) ;
@@ -119,8 +116,6 @@ export function MessageBubble({ children }: { children: ReactNode }) {
119116
120117 const overflowsLines = innerHeight > maxHeight ;
121118
122- hiddenHeight . current = innerHeight - maxHeight ;
123-
124119 setShowReadMore ( overflowsLines ) ;
125120 } ,
126121 // Note: no need to provide a dependency here (and if we provide children, this hook reruns every second for every messages).
0 commit comments