react-native-markdown-display icon indicating copy to clipboard operation
react-native-markdown-display copied to clipboard

Lists (both Ordered and Unordered) fail to render correctly if alignItems style in parent element

Open rajiv-penagonda opened this issue 1 year ago • 5 comments

Greetings, before I get started with the issue description, I want to thank you for the wonderful package that you have made. I see great potential for using this in my project where lot of help content and user readable material will have to be rendered and this tool is a gem for it.

During my evaluation, I noticed that Markdown component does not render lists correctly if the parent element View has style attribute alignItems specified to any value (center, align-start, align-end). I have attached a screenshot as well as sample code below. Could you please let me know if there is a workaround or anything I should do to use it correctly?

Regards,

failing-case.txt failing-case

rajiv-penagonda avatar Jun 12 '24 04:06 rajiv-penagonda

Just ran into this as well, however in my case the trigger was an ancestor view having a flexDirection other than column or column-reverse.

josheverett avatar Jun 27 '24 20:06 josheverett

A partial workaround is to set the following styles:

bullet_list_content: {
  flex: undefined,
},
ordered_list_content: {
  flex: undefined,
}

josheverett avatar Jun 27 '24 21:06 josheverett

Hey @josheverett, thanks for the solution. It worked like a charm, I am quite curious how you came to the discovery that an ancestor view with a flexDirection set other than column or column-reverse is causing this issue?

jordansbenjamin avatar Jul 15 '24 01:07 jordansbenjamin

@jordansbenjamin found it by just removing things until the behavior changed, plus a little trial and error. Once I found that one flexDirection value was a trigger, I tried the rest of the possible values to see which others would trigger it.

josheverett avatar Aug 06 '24 04:08 josheverett

A partial workaround is to set the following styles:

bullet_list_content: {
  flex: undefined,
},
ordered_list_content: {
  flex: undefined,
}

Might also want to add flexShrink: 1 to both, since it might cause overflow by simply setting it to undefined

Before shrink: image

After shrink: image

bvanderdrift avatar Oct 10 '24 10:10 bvanderdrift