Skip to content

Commit

Permalink
Basic error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Gleitman committed Jun 25, 2024
1 parent 3e5ec21 commit 8b9a344
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,12 @@ - (void)updateHoveredSubviewWithEvent:(NSEvent *)event

// self will always be an ancestor of any views we pass in here, so it serves as a good default option.
// Also, if we do set from/to nil, we have to call the relevant events on the entire subtree.
RCTPlatformView *commonAncestor = [(_currentHoveredSubview ?: self) ancestorSharedWithView:(hoveredView ?: self)];
RCTPlatformView *commonAncestor = [(_currentHoveredSubview ?: self) ancestorSharedWithView:(hoveredView ?: self)] ?: self;

for (RCTPlatformView *exitedView = _currentHoveredSubview; exitedView != self && exitedView != nil; exitedView = [exitedView superview]) {
for (RCTPlatformView *exitedView = _currentHoveredSubview; exitedView != commonAncestor && exitedView != nil; exitedView = [exitedView superview]) {
if (![exitedView isKindOfClass:[RCTUIView class]]) {
// TODO: error
RCTLogError(@"Unexpected view of type %@ found in hierarchy, must be RCTUIView or subclass", [exitedView class]);
continue;
}
RCTUIView *exitedReactView = (RCTUIView *)exitedView;
[self sendMouseEventWithBlock:[exitedReactView onMouseLeave]
Expand All @@ -518,9 +519,10 @@ - (void)updateHoveredSubviewWithEvent:(NSEvent *)event

// We cache these so we can call them from outermost to innermost
NSMutableArray<RCTUIView *> *enteredViewHierarchy = [NSMutableArray new];
for (RCTPlatformView *enteredView = hoveredView; enteredView != self && enteredView != nil; enteredView = [enteredView superview]) {
for (RCTPlatformView *enteredView = hoveredView; enteredView != commonAncestor && enteredView != nil; enteredView = [enteredView superview]) {
if (![enteredView isKindOfClass:[RCTUIView class]]) {
// TODO: error
RCTLogError(@"Unexpected view of type %@ found in hierarchy, must be RCTUIView or subclass", [enteredView class]);
continue;
}
[enteredViewHierarchy addObject:(RCTUIView *)enteredView];
}
Expand Down

0 comments on commit 8b9a344

Please sign in to comment.