Skip to content

Commit

Permalink
fix: long message content overflowing issue in overlay (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Sep 28, 2023
1 parent cc096ef commit 0e37670
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 197 deletions.
26 changes: 21 additions & 5 deletions package/src/components/Message/MessageSimple/utils/renderText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,27 @@ export const renderText = <
);
};

const paragraphText: ReactNodeOutput = (node, output, { ...state }) => (
<Text key={state.key} numberOfLines={messageTextNumberOfLines} style={styles.paragraph}>
{output(node.content, state)}
</Text>
);
const paragraphText: ReactNodeOutput = (node, output, { ...state }) => {
if (messageTextNumberOfLines !== undefined) {
// If we want to truncate the message text, lets only truncate the first paragraph
// and simply not render rest of the paragraphs.
if (state.key === '0' || state.key === 0) {
return (
<Text key={state.key} numberOfLines={messageTextNumberOfLines} style={styles.paragraph}>
{output(node.content, state)}
</Text>
);
} else {
return null;
}
}

return (
<Text key={state.key} style={styles.paragraph}>
{output(node.content, state)}
</Text>
);
};

const mentionedUsers = Array.isArray(mentioned_users)
? mentioned_users.reduce((acc, cur) => {
Expand Down
Loading

0 comments on commit 0e37670

Please sign in to comment.