Skip to content

Commit 0e37670

Browse files
fix: long message content overflowing issue in overlay (#2244)
1 parent cc096ef commit 0e37670

File tree

3 files changed

+237
-197
lines changed

3 files changed

+237
-197
lines changed

package/src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,27 @@ export const renderText = <
198198
);
199199
};
200200

201-
const paragraphText: ReactNodeOutput = (node, output, { ...state }) => (
202-
<Text key={state.key} numberOfLines={messageTextNumberOfLines} style={styles.paragraph}>
203-
{output(node.content, state)}
204-
</Text>
205-
);
201+
const paragraphText: ReactNodeOutput = (node, output, { ...state }) => {
202+
if (messageTextNumberOfLines !== undefined) {
203+
// If we want to truncate the message text, lets only truncate the first paragraph
204+
// and simply not render rest of the paragraphs.
205+
if (state.key === '0' || state.key === 0) {
206+
return (
207+
<Text key={state.key} numberOfLines={messageTextNumberOfLines} style={styles.paragraph}>
208+
{output(node.content, state)}
209+
</Text>
210+
);
211+
} else {
212+
return null;
213+
}
214+
}
215+
216+
return (
217+
<Text key={state.key} style={styles.paragraph}>
218+
{output(node.content, state)}
219+
</Text>
220+
);
221+
};
206222

207223
const mentionedUsers = Array.isArray(mentioned_users)
208224
? mentioned_users.reduce((acc, cur) => {

0 commit comments

Comments
 (0)