Skip to content

Commit e020576

Browse files
sherginfacebook-github-bot
authored andcommitted
TextInput on iOS: Fixing selectAll feature for multiline text input
Summary: `selectAll:` does not work for UITextView when it's being called inside UITextView's delegate methods. This is a bug in UIKit and this quite ugly workaround is only a known solution for it. Changelog: [Bug][iOS] Fixed bug in implementation of <TextInput>'s selectOnFocus prop Reviewed By: sammy-SC Differential Revision: D18966755 fbshipit-source-id: 2ba15fa94570d463a2ea3490331fb879611dc6b8
1 parent 96a6ffb commit e020576

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Libraries/Text/TextInput/Multiline/RCTUITextView.m

+11
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ - (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated
180180
[super setContentOffset:contentOffset animated:NO];
181181
}
182182

183+
- (void)selectAll:(id)sender
184+
{
185+
[super selectAll:sender];
186+
187+
// `selectAll:` does not work for UITextView when it's being called inside UITextView's delegate methods.
188+
dispatch_async(dispatch_get_main_queue(), ^{
189+
UITextRange *selectionRange = [self textRangeFromPosition:self.beginningOfDocument toPosition:self.endOfDocument];
190+
[self setSelectedTextRange:selectionRange notifyDelegate:NO];
191+
});
192+
}
193+
183194
#pragma mark - Layout
184195

185196
- (CGFloat)preferredMaxLayoutWidth

0 commit comments

Comments
 (0)