@samitouri / QOS-React-2 / commits / 6778c53c16

Modern Event System: fix bug in EnterLeave (#18849)

Dominic Gannaway committed May 7, 2020 at 00:13 UTC 6778c53c16a6cdbda04d22628a95f2e1627f3ef4
1 file changed +13 -10
packages/react-dom/src/events/plugins/ModernEnterLeaveEventPlugin.js
+13 -10
@@ -65,16 +65,18 @@ const EnterLeaveEventPlugin = {
65 topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
66 const isOutEvent =
67 topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
68 - const related = nativeEvent.relatedTarget || nativeEvent.fromElement;
69 -
70 - if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && related) {
71 - // Due to the fact we don't add listeners to the document with the
72 - // modern event system and instead attach listeners to roots, we
73 - // need to handle the over event case. To ensure this, we just need to
74 - // make sure the node that we're coming from is managed by React.
75 - const inst = getClosestInstanceFromNode(related);
76 - if (inst !== null) {
77 - return;
68 +
69 + if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) {
70 + const related = nativeEvent.relatedTarget || nativeEvent.fromElement;
71 + if (related) {
72 + // Due to the fact we don't add listeners to the document with the
73 + // modern event system and instead attach listeners to roots, we
74 + // need to handle the over event case. To ensure this, we just need to
75 + // make sure the node that we're coming from is managed by React.
76 + const inst = getClosestInstanceFromNode(related);
77 + if (inst !== null) {
78 + return;
79 + }
80 }
81 }
82
@@ -100,6 +102,7 @@ const EnterLeaveEventPlugin = {
102 let from;
103 let to;
104 if (isOutEvent) {
105 + const related = nativeEvent.relatedTarget || nativeEvent.toElement;
106 from = targetInst;
107 to = related ? getClosestInstanceFromNode(related) : null;
108 if (to !== null) {