Skip to content

Fix style update with emojis on iOS#318

Merged
tomekzaw merged 5 commits intomainfrom
@tomekzaw/fix-markdown-style-update-with-emoji
May 21, 2024
Merged

Fix style update with emojis on iOS#318
tomekzaw merged 5 commits intomainfrom
@tomekzaw/fix-markdown-style-update-with-emoji

Conversation

@tomekzaw
Copy link
Copy Markdown
Collaborator

@tomekzaw tomekzaw commented Apr 17, 2024

Details

This PR fixes formatting of the Markdown string after style and markdownStyle of MarkdownTextInput are updated, in case when the value contains an emoji.

Screen.Recording.2024-04-17.at.11.53.24.mov

This was previously fixed in #269 but it turns out that it only works correctly if the string does not contain any emojis.

The root cause of this issue is that setAttributedText skips the update if the attributed string are, however, if the string contains an emoji, the fallback mode is used and only the raw strings are compared:

https://github.com/facebook/react-native/blob/58ddd74202bede2238768def01898741606ec64f/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L128-L165

Screenshot 2024-04-17 at 11 33 09

Related Issues

Fixes #293.

Manual Tests

Repro: #293 (comment)

Linked PRs

@tomekzaw tomekzaw requested a review from Skalakid April 17, 2024 09:33
Copy link
Copy Markdown
Contributor

@Skalakid Skalakid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM however GH actions shows some warnings about undeclared selectors

#else
[_textInput setAttributedText:_textInput.attributedText]; // apply new styles
#endif
[_textInput setAttributedText:_textView.attributedText];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will _textView always be defined? It looks like if the underlying view is RCTUITextField it will be initialized, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right (as always), changed in 8720e3e, now it works both for singleline and multiline.

@tomekzaw tomekzaw requested a review from j-piasecki May 21, 2024 07:58
j-piasecki
j-piasecki previously approved these changes May 21, 2024
Copy link
Copy Markdown
Collaborator

@j-piasecki j-piasecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please make CI happy 😄

@tomekzaw
Copy link
Copy Markdown
Collaborator Author

I forgot about Fabric 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MarkdownStyles updated with delay on iOS

3 participants