Skip to content

Commit 120c7f8

Browse files
zuizuihaojaviercn
authored andcommitted
[Blazor] Avoid calling dispatchGlobalEventToAllElements when no renderer attached (#58667)
* Prevents an issue where the event tries to get dispatched when no renderer is attached. --------- Co-authored-by: Javier Calvarro Nelson <[email protected]>
1 parent 76d9769 commit 120c7f8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 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,11 @@ 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+
return;
142+
}
143+
139144
// Always dispatch to any listeners for the original underlying browser event name
140145
this.dispatchGlobalEventToAllElements(evt.type, evt);
141146

0 commit comments

Comments
 (0)