Skip to content

Commit e38be82

Browse files
Peter Arganyfacebook-github-bot
Peter Argany
authored andcommittedFeb 22, 2019
Revert of [D13948951]Apply the fix for CJK languages on single-line test fields.
Summary: This PR (#22546) broke single line text inputs. After inputting some text and tapping away, the text input reverts back to default text. Revert solved the issue. Reviewed By: cpojer Differential Revision: D14185897 fbshipit-source-id: cc7f0f2ebfb0494062afbc628c4fe27ad27fb1c6
1 parent 4a5266c commit e38be82

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed
 

‎Libraries/Text/TextInput/Singleline/RCTUITextField.m

-44
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
@implementation RCTUITextField {
1616
RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter;
17-
NSMutableAttributedString *_attributesHolder;
1817
}
1918

2019
- (instancetype)initWithFrame:(CGRect)frame
@@ -26,7 +25,6 @@ - (instancetype)initWithFrame:(CGRect)frame
2625
object:self];
2726

2827
_textInputDelegateAdapter = [[RCTBackedTextFieldDelegateAdapter alloc] initWithTextField:self];
29-
_attributesHolder = [[NSMutableAttributedString alloc] init];
3028
}
3129

3230
return self;
@@ -119,48 +117,6 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position
119117
return [super caretRectForPosition:position];
120118
}
121119

122-
#pragma mark - Fix for CJK Languages
123-
124-
/*
125-
* The workaround to fix inputting complex locales (like CJK languages).
126-
* When we use `setAttrbutedText:` while user is inputting text in a complex
127-
* locale (like Chinese, Japanese or Korean), some internal state breaks and
128-
* input stops working.
129-
*
130-
* To workaround that, we don't skip underlying attributedString in the text
131-
* field if only attributes were changed. We keep track of these attributes in
132-
* a local variable.
133-
*
134-
* There are two methods that are altered by this workaround:
135-
*
136-
* (1) `-setAttributedText:`
137-
* Applies the attributed string change to a local variable `_attributesHolder` instead of calling `-[super setAttributedText:]`.
138-
* If new attributed text differs from the existing one only in attributes,
139-
* skips `-[super setAttributedText:`] completely.
140-
*
141-
* (2) `-attributedText`
142-
* Return `_attributesHolder` context.
143-
* Updates `_atributesHolder` before returning if the underlying `super.attributedText.string` was changed.
144-
*
145-
*/
146-
- (void)setAttributedText:(NSAttributedString *)attributedText
147-
{
148-
BOOL textWasChanged = ![_attributesHolder.string isEqualToString:attributedText.string];
149-
[_attributesHolder setAttributedString:attributedText];
150-
151-
if (textWasChanged) {
152-
[super setAttributedText:attributedText];
153-
}
154-
}
155-
156-
- (NSAttributedString *)attributedText
157-
{
158-
if (![super.attributedText.string isEqualToString:_attributesHolder.string]) {
159-
[_attributesHolder setAttributedString:super.attributedText];
160-
}
161-
162-
return _attributesHolder;
163-
}
164120

165121
#pragma mark - Positioning Overrides
166122

0 commit comments

Comments
 (0)
Please sign in to comment.