From 724134746bb1887ecf18fd93a420f6bbfbaaf2af Mon Sep 17 00:00:00 2001 From: Nathan Azaria Date: Fri, 3 Jun 2016 16:08:34 -0700 Subject: [PATCH] Changed RCTTextView to check for failed focus Reviewed By: nicklockwood Differential Revision: D3378236 fbshipit-source-id: b4a33f7808ffe116b51631cde35f5cd0042caee9 --- Libraries/Text/RCTTextView.m | 8 ++++++++ React/Modules/RCTUIManager.m | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index d32463333..84e83214f 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -48,6 +48,14 @@ _jsRequestingFirstResponder = NO; } +- (void)didMoveToWindow +{ + if (_jsRequestingFirstResponder) { + [self becomeFirstResponder]; + [self reactDidMakeFirstResponder]; + } +} + @end @implementation RCTTextView diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 033df4de6..10ee2152d 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -1032,8 +1032,9 @@ RCT_EXPORT_METHOD(focus:(nonnull NSNumber *)reactTag) [self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { UIView *newResponder = viewRegistry[reactTag]; [newResponder reactWillMakeFirstResponder]; - [newResponder becomeFirstResponder]; - [newResponder reactDidMakeFirstResponder]; + if ([newResponder becomeFirstResponder]) { + [newResponder reactDidMakeFirstResponder]; + } }]; }