-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[iOS] Fix textAttributes not applied when typing text #23585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some snapshot tests are failling, can you check if its related to this pr and fix those? Probably just need to update them if the changes are expected.
@janicduplessis Thanks for review, I scan the failed tests, seems the failed snapshot tests not related to So I think it needs to fix by another |
👍 I just double checked and you are right it is for other components. I think you have to use xcode to update the snapshots but I've never done it either haha. |
@@ -88,6 +91,20 @@ - (void)setPlaceholderColor:(UIColor *)placeholderColor | |||
_placeholderView.textColor = _placeholderColor ?: defaultPlaceholderColor(); | |||
} | |||
|
|||
- (void)setReactTextAttributes:(RCTTextAttributes *)reactTextAttributes | |||
{ | |||
if (!reactTextAttributes.effectiveTextAttributes || [reactTextAttributes isEqual:_reactTextAttributes]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a variable for effectiveTextAttributes
to avoid computing it twice, looks like a pretty big getter
- (NSDictionary<NSAttributedStringKey, id> *)effectiveTextAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janicduplessis 👍 I removed !reactTextAttributes.effectiveTextAttributes
check because it cannot be nil
.
@@ -62,6 +65,20 @@ - (void)setPlaceholderColor:(UIColor *)placeholderColor | |||
[self _updatePlaceholder]; | |||
} | |||
|
|||
- (void)setReactTextAttributes:(RCTTextAttributes *)reactTextAttributes | |||
{ | |||
if (!reactTextAttributes.effectiveTextAttributes || [reactTextAttributes isEqual:_reactTextAttributes]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@zhongwuzw can you update the screenshot examples? |
@cpojer I don't know why here failed 🤔 , seems all other
_runner.recordMode = YES ?
|
Yeah I think that's it. |
@zhongwuzw Looks like tests are passing on master, maybe you can just try rebasing see if it fixes it? |
[iOS] Fix textAttributes not applied when typing text Remove dead code
4901a12
to
ebaa9bb
Compare
@cpojer @janicduplessis CI passes! 🍻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This diff changes how we apply default text attributes to backed text input. The original change in #23585 that introduced the `reactTextAttributes` field in for RCTBackedTextInputViewProtocol was great! Thank you Wu zhongwuzw ! However, there is one detail that needs to be changed. RCTBackedTextInputViewProtocol is designed to only abstract complexity of iOS text input components (UITextView and UITextField); it intentionally does not have any React-specific fields or types. Adding a field `RCTTextAttributes *reactTextAttributes;` violates this principle and make it hard to reuse this functionality in the new Fabric-powered TextInput. This diff changes the type of this prop from `RCTTextAttributes` to `NSDictionary<NSAttributedStringKey,id> *` (exact same type that UITextView and UITextField use). Reviewed By: cpojer Differential Revision: D17408501 fbshipit-source-id: 65f2bba119ccc30f22e87c28d0f8ea6f731cd365
Summary
Currently, if we has
defaultValue
, textAttributes likeletterSpacing
can works, but if textinput has not default text, when we typing the text, some attributes not applied.Changelog
[iOS] [Fixed] - Fix textAttributes not applied when typing text
Test Plan
We can use code like below,
letterSpacing
not work previously.Before:
If we have
defaultValue
,letterSpacing
works:After: