Fix the bug where key shortcuts are invoked in TextInputs in iOS

Summary:
This is a followup for "Add Shortcut "Double R" to Reload JS in iOS".
Please see the previous two revisions:[[ D3371536 | D3371536 ]], [[ D3343907 | D3343907 ]]

In previous revisions, we only tested with the iOS UIExplorer app, without testing in the iOS Catalyst app, where the key shortcuts we added are always invoked in TextInput components. It's due to a bug with the `UIApplicationDelegate`. Just fix this bug in this revision and successfully tested in the Catalyst app.

Reviewed By: mkonicek

Differential Revision: D3391045

fbshipit-source-id: 8b76fbfe7592218b02dd22502d25eebbc59f3cbc
This commit is contained in:
Siqi Liu 2016-06-06 09:30:56 -07:00 committed by Facebook Github Bot 4
parent 5b4b027477
commit 61046c3195
1 changed files with 2 additions and 6 deletions

View File

@ -113,15 +113,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
* For example, double-pressing a key should type two characters into the text view,
* not invoke a predefined keyboard shortcut.
*/
NSString *name = NSStringFromClass(self.class);
if ([name isEqualToString : @"AppDelegate"]) {
return nil;
}
UIResponder *firstResponder = [UIResponder RCT_getFirstResponder: self];
if ([firstResponder isKindOfClass:[UITextView class]] ||
[firstResponder isKindOfClass:[UITextField class]] ||
[firstResponder conformsToProtocol:@protocol(UITextViewDelegate)]) {
[firstResponder conformsToProtocol:@protocol(UITextViewDelegate)] ||
[self conformsToProtocol:@protocol(UIApplicationDelegate)]) {
return nil;
}