File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
packages/react-native/React/Views Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -1492,16 +1492,21 @@ - (BOOL)acceptsFirstResponder
1492
1492
1493
1493
- (void )updateTrackingAreas
1494
1494
{
1495
- if (_trackingArea) {
1496
- [self removeTrackingArea: _trackingArea];
1497
- }
1495
+ BOOL hasMouseHoverEvent = self.onMouseEnter || self.onMouseLeave ;
1496
+ BOOL wouldRecreateIdenticalTrackingArea = hasMouseHoverEvent && _trackingArea && NSEqualRects (self.bounds , [_trackingArea rect ]);
1497
+
1498
+ if (!wouldRecreateIdenticalTrackingArea) {
1499
+ if (_trackingArea) {
1500
+ [self removeTrackingArea: _trackingArea];
1501
+ }
1498
1502
1499
- if (self.onMouseEnter || self.onMouseLeave ) {
1500
- _trackingArea = [[NSTrackingArea alloc ] initWithRect: self .bounds
1501
- options: NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1502
- owner: self
1503
- userInfo: nil ];
1504
- [self addTrackingArea: _trackingArea];
1503
+ if (hasMouseHoverEvent) {
1504
+ _trackingArea = [[NSTrackingArea alloc ] initWithRect: self .bounds
1505
+ options: NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1506
+ owner: self
1507
+ userInfo: nil ];
1508
+ [self addTrackingArea: _trackingArea];
1509
+ }
1505
1510
}
1506
1511
1507
1512
[super updateTrackingAreas ];
You can’t perform that action at this time.
0 commit comments