Skip to content

Commit cf5aa57

Browse files
committed
Fix issue with event delegation when renderer is not attached
1 parent 23cb501 commit cf5aa57

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Components/Web.JS/src/Rendering/Events/EventDelegator.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { EventFieldInfo } from './EventFieldInfo';
55
import { eventNameAliasRegisteredCallbacks, getBrowserEventName, getEventNameAliases, getEventTypeOptions } from './EventTypes';
6-
import { dispatchEvent } from '../WebRendererInteropMethods';
6+
import { isRendererAttached, dispatchEvent } from '../WebRendererInteropMethods';
77

88
const nonBubblingEvents = toLookup([
99
'abort',
@@ -136,6 +136,13 @@ export class EventDelegator {
136136
return;
137137
}
138138

139+
if (!isRendererAttached(this.browserRendererId)) {
140+
// when connection closed, it will detachWebRendererInterop, so we need to check if the renderer is still attached
141+
const targetElement = evt.target as Element;
142+
console.warn(`${evt.type} on ${targetElement.localName}${targetElement.className ? ' with class ' + targetElement.className : ''} is not handled because the renderer is not attached`);
143+
return;
144+
}
145+
139146
// Always dispatch to any listeners for the original underlying browser event name
140147
this.dispatchGlobalEventToAllElements(evt.type, evt);
141148

0 commit comments

Comments
 (0)