Skip to content

Commit

Permalink
Update RCTView.m
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi authored Jan 3, 2023
1 parent 4f6c4eb commit 09137a9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1675,13 +1675,6 @@ - (RCTViewKeyboardEvent*)keyboardEvent:(NSEvent*)event {
return [RCTViewKeyboardEvent keyEventFromEvent:event reactTag:self.reactTag];
}

// If validKeysUp or validKeysDown is defined, use the legacy keyboard event handling behavior
- (void)shouldUseLegacyKeyboardBehaviorForEvent:(NSEvent*)event {
BOOL keyDown = event.type == NSEventTypeKeyDown;
NSArray<NSString *> *validKeys = keyDown ? [self validKeysDown] : [self validKeysUp];
return (validKeys == nil);
}

// Only send events to JS that are defined in validKeysDown. Bubbling happens only natively
- (BOOL)handleKeyboardEventLegacy:(NSEvent *)event {
if (event.type == NSEventTypeKeyDown ? self.onKeyDown : self.onKeyUp) {
Expand Down Expand Up @@ -1718,6 +1711,13 @@ - (BOOL)handleKeyboardEventModern:(NSEvent*)event {
return shouldSuppressNativeHandling;
}

// If validKeysUp or validKeysDown is defined, use the legacy keyboard event handling behavior
- (void)shouldUseLegacyKeyboardBehaviorForEvent:(NSEvent*)event {
BOOL keyDown = event.type == NSEventTypeKeyDown;
NSArray<NSString *> *validKeys = keyDown ? [self validKeysDown] : [self validKeysUp];
return (validKeys == nil);
}

- (void)keyDown:(NSEvent *)event {
BOOL shouldUseLegacyBehavior = [self shouldUseLegacyKeyboardBehaviorForEvent:event];

Expand Down

0 comments on commit 09137a9

Please sign in to comment.