Skip to content

Commit 9b2d400

Browse files
committed
Apply change from #1971 to Fabric
1 parent 5f334af commit 9b2d400

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,21 +1761,22 @@ - (void)viewDidMoveToWindow
17611761

17621762
- (void)updateTrackingAreas
17631763
{
1764-
if (_trackingArea) {
1765-
[self removeTrackingArea:_trackingArea];
1766-
}
1767-
17681764
BOOL hasMouseEventHandler =
17691765
_props->hostPlatformEvents[HostPlatformViewEvents::Offset::MouseEnter] ||
17701766
_props->hostPlatformEvents[HostPlatformViewEvents::Offset::MouseLeave];
1767+
BOOL wouldRecreateIdenticalTrackingArea =
1768+
hasMouseEventHandler && _trackingArea && NSEqualRects(self.bounds, [_trackingArea rect]);
17711769

1772-
if (hasMouseEventHandler) {
1773-
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
1774-
options:NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited
1775-
owner:self
1776-
userInfo:nil];
1777-
[self addTrackingArea:_trackingArea];
1778-
[self updateMouseOverIfNeeded];
1770+
if (!wouldRecreateIdenticalTrackingArea) {
1771+
[self removeTrackingArea:_trackingArea];
1772+
if (hasMouseEventHandler) {
1773+
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
1774+
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
1775+
owner:self
1776+
userInfo:nil];
1777+
[self addTrackingArea:_trackingArea];
1778+
[self updateMouseOverIfNeeded];
1779+
}
17791780
}
17801781

17811782
[super updateTrackingAreas];

0 commit comments

Comments
 (0)