File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const state = {
16
16
settings : {
17
17
testIdAttribute : 'data-testid' ,
18
18
} ,
19
+ pointerInside : false ,
19
20
} ;
20
21
21
22
function postMessage ( action ) {
@@ -106,12 +107,16 @@ function Sandbox() {
106
107
< div
107
108
className = "pr-1 relative w-screen h-screen overflow-hidden"
108
109
onMouseEnter = { ( ) => {
110
+ state . pointerInside = true ;
109
111
state . highlighter ?. clear ( ) ;
110
112
state . highlighter ?. start ( { stopOnClick : false , blockEvents : false } ) ;
111
113
} }
112
114
onMouseLeave = { ( ) => {
113
115
state . highlighter ?. stop ( ) ;
114
116
state . highlighter . highlight ( { nodes : state . queriedNodes } ) ;
117
+ state . pointerInside = false ;
118
+
119
+ postMessage ( { type : 'HOVER_NODE' , payload : null } ) ;
115
120
} }
116
121
>
117
122
< Scrollable forwardedRef = { setRootNode } id = "sandbox" />
@@ -120,7 +125,11 @@ function Sandbox() {
120
125
}
121
126
122
127
function onSelectNode ( node , { origin } ) {
123
- if ( ! origin || origin === 'script' ) {
128
+ // onSelectNode can be triggered after onMouseLeave has already been called.
129
+ // This makes it impossible to clear hover state. That's why we maintain and
130
+ // check a boolean to see if the pointer is inside the sandbox, before
131
+ // dispatching events.
132
+ if ( ! origin || origin === 'script' || ! state . pointerInside ) {
124
133
return ;
125
134
}
126
135
You can’t perform that action at this time.
0 commit comments