Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collapsible markdown images #26905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tdwio
Copy link

@tdwio tdwio commented Apr 29, 2024

Summary

Fix collapsing markdown images

Ticket Link

N/A

Screenshots

  • Before
Screen.Recording.2024-04-29.at.09.55.43.mov
  • After
Screen.Recording.2024-04-29.at.09.55.53.mov

Release Note

Fix collapsible markdown images

@mattermost-build
Copy link
Contributor

Hello @tdwio,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@mm-cloud-bot mm-cloud-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 29, 2024
@M-ZubairAhmed
Copy link
Member

@tdwio do we have a ticket for this?

@hanzei hanzei requested review from a team and hmhealey and removed request for a team April 30, 2024 13:22
@hanzei hanzei added 2: Dev Review Requires review by a developer 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review labels Apr 30, 2024
@mattermost-build
Copy link
Contributor

E2E tests not automatically triggered, because the PR is not in a mergeable state. Please update the branch with the base branch and resolve outstanding conflicts.

@tdwio tdwio force-pushed the fix-collapsible-markdown-images branch from ec4e339 to b9df2aa Compare April 30, 2024 15:38
@tdwio
Copy link
Author

tdwio commented Apr 30, 2024

@tdwio do we have a ticket for this?

I have not found any related issue. However, the original feature came from this pull-request : mattermost/mattermost-webapp#7352, so I assumed this is a bug

@hmhealey
Copy link
Member

hmhealey commented May 1, 2024

Great find! I'm surprised that the tests for this didn't catch the issue, but perhaps there's a case we missed here.

Playing around with this myself without your changes, I've noticed that the image isn't collapsible right when it's posted, but becomes collapsible after I refresh. Do you see the same thing?

It seems like there's an underlying bug here where imageMetadata is empty when a post is first made which can cause some other issues like messing up the scroll position of the post list. Would you be interested in looking into that at all? If not, that's totally fine though since I can just file a separate ticket to investigate that.

@tdwio
Copy link
Author

tdwio commented May 3, 2024

Playing around with this myself without your changes, I've noticed that the image isn't collapsible right when it's posted, but becomes collapsible after I refresh. Do you see the same thing?

I see the same thing. Also, if you edit a post and add a markdown image it will be collapsible

It seems like there's an underlying bug here where imageMetadata is empty when a post is first made which can cause some other issues like messing up the scroll position of the post list. Would you be interested in looking into that at all? If not, that's totally fine though since I can just file a separate ticket to investigate that.

I will look into that

@tdwio tdwio force-pushed the fix-collapsible-markdown-images branch from b9df2aa to d2d2820 Compare May 3, 2024 08:45
@tdwio
Copy link
Author

tdwio commented May 3, 2024

@hmhealey

I have found that imagesMetadata object have keys with normal image URLs (example : https://media1.giphy.com/media/VqztgK1DlT5JzPBPuR/200.gif) whereas attribs.src from messageHtmlToComponent refers to a proxied image URL (example: https://test.proxy/api/v4/image?url=[...]. Like you said, this caused imageMetadata to be undefined causing gifs/images to not be collapsible. Sometimes those URLs also have encoded ampersand &.

I have removed my original edits and pushed modifications to messageHtmlToComponent and necessary tests 👍

@tdwio tdwio force-pushed the fix-collapsible-markdown-images branch from d2d2820 to 60a6826 Compare May 3, 2024 08:55
@hmhealey
Copy link
Member

hmhealey commented May 6, 2024

Great find. I'll try to take a look at this tomorrow since I want to see if I can find why the metadata still seems to be different on first post vs afterwards, but making sure that the clientside code can handle that sounds like a good fix. We've had issues with proxied URLs not being consistently returned by the server before, so it'll be nice to know that the web app can handle that too

@mattermost-build
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a developer 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review Contributor Lifecycle/1:stale release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants