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 style update with emojis on iOS #318

Merged
merged 5 commits into from
May 21, 2024

Conversation

tomekzaw
Copy link
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
Collaborator

@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
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
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
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
Collaborator Author

I forgot about Fabric 😢

@tomekzaw tomekzaw merged commit 268c33f into main May 21, 2024
5 checks passed
@tomekzaw tomekzaw deleted the @tomekzaw/fix-markdown-style-update-with-emoji branch May 21, 2024 09:39
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