no dispatchGlobalEventToAllElements when no renderer attached #58667
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ROOT CAUSE
when Blazor connection closed, the detachWebRendererInterop in the callback of connection.onclose will be invoked. here, it will invoke interopMethodsByRenderer.delete(rendererId);, all the interopMethodsByRenderer will be cleaned. also There are lots of global event listener in form.js like window.addEventListener('focus'), window.addEventListener('keydown'). if user still interact with our app like focus, click, the global event will be triggered, then invoked EventDelegator.onGlobalEvent, invoked EventDelegator.dispatchGlobalEventToAllElements invoked WebRendererInteropMethods.dispatchEvent invoked WebRendererInteropMethods.getInteropMethods, here since the interopMethodsByRenderer is empty, will throw this exception.
SOLUTION:
check isRendererAttached before dispatchGlobalEventToAllElements in EventDelegator
Fixes #57828
Before Fixes:
After Fixes: