Rocket.Chat.ReactNative icon indicating copy to clipboard operation
Rocket.Chat.ReactNative copied to clipboard

bug: Markdown Image not rendering correctly

Open diegolmello opened this issue 1 year ago • 8 comments

Describe the Bug

Image is rendering on top of the rest of the content.

Steps to Reproduce

  • Apply the following code here https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/037253bdf26fde48e320f3a61350d8b343dfa090/app/containers/markdown/Markdown.stories.tsx#L134
  • Inspect MarkdownImage on Storybook
const mdText = `${lineBreakText} ![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)`

export const Image = () => (
	<View style={styles.container}>
		<Markdown msg={mdText} />
		<View style={{ height : 1, backgroundColor : 'red' }} />
		<RNText>{lineBreakText} <RNImage source={{ uri: 'https://play.google.com/intl/en_us/badges/images/badge_new.png' }} style={{ width: 100, height: 100 }} /></RNText>
	</View>
);

I've added a red line to display where Markdown ends and where the Text sample starts.

Expected Behavior

No response

Actual Behavior

Image

Rocket.Chat Server Version

any

Rocket.Chat App Version

4.58.0

Device Name

any

OS Version

any

Additional Context

No response

diegolmello avatar Mar 14 '25 18:03 diegolmello

Hi @diegolmello, I would love to work on this issue as part of my GSoC 2025 contribution! 🚀 I have experience in React Native, UI debugging, and frontend fixes.

Please assign me this issue, and I’ll begin working on a fix. Thanks!

TapItNinja avatar Mar 15 '25 23:03 TapItNinja

@TapItNinja Hey! There's no assignment. Open a PR and we're going to review it. Thanks!

diegolmello avatar Mar 17 '25 13:03 diegolmello

I'm unable to produce it using the storyboard. Please help me to provide more details about these bugs.

JASIM0021 avatar Mar 22 '25 18:03 JASIM0021

The issue has been fixed, and I have made the image height and width dynamic based on the remote image size.

Please review my PR and merge it. Here is a screenshot of the fixed screen.

Image

JASIM0021 avatar Mar 23 '25 05:03 JASIM0021

It appears to be a bug on React Native, so we can't solve on our side alone. At least not without refactoring and trying new things. We would have to render inline images outside of a Text node that contains a lineHeight style.

https://github.com/facebook/react-native/issues/48727

diegolmello avatar Apr 01 '25 16:04 diegolmello

Feel free to use this channel to test markdown https://open.rocket.chat/channel/markdown-parser

As a reference, if you comment this two lines on Markdown styles, you'll see the inline image rendering correctly

Image

diegolmello avatar Apr 01 '25 16:04 diegolmello

@diegolmello I would like to work on it..

Demiserular avatar Apr 04 '25 11:04 Demiserular

Fabric doesn't seem to fix it https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/6478#issuecomment-3141099169

diegolmello avatar Jul 31 '25 19:07 diegolmello