File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
ts/components/conversation/message/message-content Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,12 @@ export function MessageBubble({ children }: { children: ReactNode }) {
89
89
setExpanded ( true ) ;
90
90
} ;
91
91
92
+ /**
93
+ * Used to re-trigger the "Read More" layout effect when the message content changes scroll height.
94
+ * This is required to handle window resizing, zooming, and font size changes.
95
+ */
96
+ const scrollHeight = msgBubbleRef . current ?. firstElementChild ?. scrollHeight ;
97
+
92
98
useLayoutEffect (
93
99
( ) => {
94
100
const el = msgBubbleRef ?. current ?. firstElementChild ;
@@ -118,9 +124,12 @@ export function MessageBubble({ children }: { children: ReactNode }) {
118
124
119
125
setShowReadMore ( overflowsLines ) ;
120
126
} ,
121
- // Note: no need to provide a dependency here (and if we provide children, this hook reruns every second for every messages).
122
- // The only dependency is msgBubbleRef, but as it's a ref it's unneeded
123
- [ ]
127
+ /**
128
+ * Note: Don't provide children as a dependency, if you do this hook reruns every second for every
129
+ * message. The only dependencies are the scrollHeight (to handle window resizing) and msgBubbleRef,
130
+ * but it's a ref so is not needed.
131
+ */
132
+ [ scrollHeight ]
124
133
) ;
125
134
126
135
return (
You can’t perform that action at this time.
0 commit comments