An error is thrown:
Error: System.ArgumentException: There is no event handler associated with this event. EventId: '3'. (Parameter 'eventHandlerId')
when an element with focusout handler is removed from the DOM in a blazor wasm app (both 3.1 and 5.0).
Index.razor page, click on item 2 that has @onfocusout handlerNote: The main logic is part of the Index.razor page only and the script.js file.
Error: System.ArgumentException: There is no event handler associated with this event. EventId: '3'. (Parameter 'eventHandlerId')
dotnet --infoA similar problem is marked to be fixed in multiple cases like:
https://github.com/dotnet/aspnetcore/issues/17926
https://github.com/dotnet/aspnetcore/issues/21241
https://github.com/dotnet/aspnetcore/issues/21366
https://github.com/dotnet/aspnetcore/issues/21874#issuecomment-632814894
but the problem is still reproducible in both the 3.1 and 5.0 versions.
Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
I did some investigation on this today, and confirmed it is a current bug. The repro can be simplified to:
@if (showButtonThatDisappearsWhenClicked)
{
<button @onfocusout="HandleFocusOut" @onclick="HandleClick">Click me</button>
}
@code {
bool showButtonThatDisappearsWhenClicked = true;
void HandleClick()
{
Console.WriteLine("click");
showButtonThatDisappearsWhenClicked = false;
}
void HandleFocusOut()
{
Console.WriteLine("focusout");
}
}
This works OK on Blazor Server but throws on Blazor WebAssembly. On wasm, the sequence of events is:
JS: Notify click event
Next clock tick:
Possible resolution:
With .NET5 RC2 it seems to be working even with Blazor WebAssembly. Did not get any error. But VS 2019 Intelligense does not show this event handler only onfucus:

@majorimi It's not clear to me that what you're posting here is the same thing as this issue. Instead of posting here, could you please file a new issue giving a clear description of what you're doing (since it's likely totally different)?
@SteveSandersonMS: I was trying out @onfocusout event with a very similar code as your example above. Run it in a Blazor WebAssembly (not server side) project and I received the events without exceptions. So just confirmed bug was fixed...
Also my point was if this event is supported by Blazor and works perfectly, why Visual Studio 2019 Intelligense is not offering it when I'm typing focus keyword?
As you can see on that screenshot Intelligense has 1 result for @onfocus however it should match with 2 items: @onfocus and @onfocusout as well.
Sure lets post it to a new issue, however not sure if is it belongs to this repo or should be posted for VS team? Thanks.
Sure lets post it to a new issue
Yes please, in this repo.
Just a note that this breaks data binding scenarios:
I haven't found a reliable workaround. Changing the bind:event to oninput works, but only when binding is appropriate for that event. A workaround for this would be great.
I am also facing the same script issue.
Any workarounds for resolving this ?
@RobertBouillon @Indrajith-Sync If you could each post separate issues with your own minimal repro steps, we can figure out whether it鈥檚 the same issue or not. Thanks!
@SteveSandersonMS Can you clarify if a potential fix will be backported to the 3.x branch or will it be part of the upcoming 5.0.1 release only? I need to support both 3.x and 5.0, so this information will be helpful to me beforehand.
We don't have a decision about that yet, however as a caution, please note that 3.2.0 is not an LTS release and hence doesn't come with support beyond (I think) February 2021. Developers using Blazor WebAssembly should upgrade to 5.0 before February 2021.
You are probably referring to the 6.0-preview1 milestone targeting February 10, 2021 for an end date for wasm 3.2.0, but are any fixes for wasm going to be part of any of the 3.1.x releases? As far as I understand, Blazor WebAssembly 3.2.0 is not considered to be connected with the 3.1 LTS (ending on December 3, 2022), but I cannot find any official statement about that, am I correct?
You can find out more about support policy and roadmap at https://dotnet.microsoft.com/platform/support/policy/dotnet-core. You are correct that 3.2.x is not part of the 3.1.x LTS release (in fact, that's why we gave it the 3.2.0 version originally).
Most helpful comment
I did some investigation on this today, and confirmed it is a current bug. The repro can be simplified to:
This works OK on Blazor Server but throws on Blazor WebAssembly. On wasm, the sequence of events is:
JS: Notify click event
Next clock tick:
Possible resolution:
inside the deferral callback, not outside it (as we do today). Then in this case we'd never dispatch the 'focusout' event to .NET,
so there'd be no exception, but also no call to the focusout handler.
deliver it before the first 'batch complete' confirmation, and hence the 'focusout' event would fire.
a renderbatch finished application, before releasing its event handlers we execute any deferred event notifications