Expensify / react-native-live-markdown

Drop-in replacement for React Native's TextInput component with Markdown formatting.
https://www.npmjs.com/package/@expensify/react-native-live-markdown
MIT License
789 stars 56 forks source link

Cannot select single words on first attempt in text with headings or blockquotes on iOS #417

Open QichenZhu opened 3 months ago

QichenZhu commented 3 months ago

When attempting to select a single word in text that contains headings or blockquotes, the selection does not work on the first try.

Video

https://github.com/Expensify/react-native-live-markdown/assets/57348009/c2991145-2ecf-44d9-8942-866cb7f32c9d

QichenZhu commented 3 months ago

@tomekzaw I came across this while testing https://github.com/Expensify/App/issues/44495, and my PR doesn't fix it, so I reported this new issue. Still, I believe the root cause and solution might be similar.

tomekzaw commented 2 months ago

This problem is particularly visible when typing fast inside the component that contains blockquotes:

Bold Blockquote

I believe the problem is caused by NSMutableParagraphStyle. The problem no longer exists when I remove NSMutableParagraphStyle (but obviously there's no padding then). Also, it helps when I make the MarkdownTextInput component uncontrolled. Finally, making the JS thread busy also improves the behavior.