From cf40f44023c123cd628d2fe952264faf0a91fd5f Mon Sep 17 00:00:00 2001 From: Arya Khochare <91268931+Aryakoste@users.noreply.github.com> Date: Wed, 8 Apr 2026 00:11:03 +0530 Subject: [PATCH] Markdown message preview fixed (#34942) * markdown message preview fixed * message preview overflow fix * fix show_more test * restore package-lock.json * pull package-lock from master * package-lock line break * Fix missing newline at end of package-lock.json * Update test snapshots --------- Co-authored-by: David Krauser Co-authored-by: Mattermost Build Co-authored-by: David Krauser --- .../post_message_preview.test.tsx.snap | 16 ++++---- .../post_message_preview.tsx | 2 +- .../__snapshots__/show_more.test.tsx.snap | 38 +++++++++++++++++++ .../post_view/show_more/show_more.test.tsx | 30 +++++++++++++++ .../post_view/show_more/show_more.tsx | 4 +- 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/webapp/channels/src/components/post_view/post_message_preview/__snapshots__/post_message_preview.test.tsx.snap b/webapp/channels/src/components/post_view/post_message_preview/__snapshots__/post_message_preview.test.tsx.snap index ea1563bbf8c..e176816913b 100644 --- a/webapp/channels/src/components/post_view/post_message_preview/__snapshots__/post_message_preview.test.tsx.snap +++ b/webapp/channels/src/components/post_view/post_message_preview/__snapshots__/post_message_preview.test.tsx.snap @@ -64,7 +64,7 @@ exports[`PostMessagePreview direct and group messages should render preview for >
{ diff --git a/webapp/channels/src/components/post_view/show_more/__snapshots__/show_more.test.tsx.snap b/webapp/channels/src/components/post_view/show_more/__snapshots__/show_more.test.tsx.snap index ad77aa4d8c8..9c2b3bc67d1 100644 --- a/webapp/channels/src/components/post_view/show_more/__snapshots__/show_more.test.tsx.snap +++ b/webapp/channels/src/components/post_view/show_more/__snapshots__/show_more.test.tsx.snap @@ -127,6 +127,25 @@ exports[`components/post_view/ShowMore should match snapshot, PostMessageView on
`; +exports[`components/post_view/ShowMore should match snapshot, PostMessageView on collapsed view with ellipsis overflow 1`] = ` +
+
+
+ +
+
+`; + exports[`components/post_view/ShowMore should match snapshot, PostMessageView on expanded view 1`] = `
`; + +exports[`components/post_view/ShowMore should match snapshot, PostMessageView on expanded view with ellipsis overflow 1`] = ` +
+
+
+ +
+
+`; diff --git a/webapp/channels/src/components/post_view/show_more/show_more.test.tsx b/webapp/channels/src/components/post_view/show_more/show_more.test.tsx index aaaad38e920..cb3a361b100 100644 --- a/webapp/channels/src/components/post_view/show_more/show_more.test.tsx +++ b/webapp/channels/src/components/post_view/show_more/show_more.test.tsx @@ -82,6 +82,36 @@ describe('components/post_view/ShowMore', () => { expect(container).toMatchSnapshot(); }); + test('should match snapshot, PostMessageView on collapsed view with ellipsis overflow', () => { + const ref = React.createRef(); + const {container} = renderWithContext( + , + ); + act(() => { + ref.current?.setState({isOverflow: true, isCollapsed: true}); + }); + expect(container).toMatchSnapshot(); + }); + + test('should match snapshot, PostMessageView on expanded view with ellipsis overflow', () => { + const ref = React.createRef(); + const {container} = renderWithContext( + , + ); + act(() => { + ref.current?.setState({isOverflow: true, isCollapsed: false}); + }); + expect(container).toMatchSnapshot(); + }); + test('should match snapshot, PostMessageView on expanded view with compactDisplay', () => { const ref = React.createRef(); const {container} = renderWithContext( diff --git a/webapp/channels/src/components/post_view/show_more/show_more.tsx b/webapp/channels/src/components/post_view/show_more/show_more.tsx index bf5c5b067da..df9241dcf33 100644 --- a/webapp/channels/src/components/post_view/show_more/show_more.tsx +++ b/webapp/channels/src/components/post_view/show_more/show_more.tsx @@ -114,8 +114,10 @@ export default class ShowMore extends React.PureComponent { let className = 'post-message'; let collapsedMaxHeightStyle: number | undefined; if (isCollapsed) { - collapsedMaxHeightStyle = this.maxHeight; className += ' post-message--collapsed'; + if (!(overflowType === 'ellipsis' && isOverflow)) { + collapsedMaxHeightStyle = this.maxHeight; + } } else { className += ' post-message--expanded'; }