Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blur event inside form can cause "no event handler associated with this event" exception #21241

Closed
SteveSandersonMS opened this issue Apr 27, 2020 · 7 comments · Fixed by #24684
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Milestone

Comments

@SteveSandersonMS
Copy link
Member

Scenario:

<EditForm OnValidSubmit="NavigateToAnotherPage">
    <input @blur="@(() => {})" />
</EditForm>

Pressing "enter" inside the input causes:

System.ArgumentException: There is no event handler associated with this event. EventId: '45'.
Parameter name: eventHandlerId
  at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync (:44300/System.UInt64 eventHandlerId, Microsoft.AspNetCore.Components.RenderTree.EventFieldInfo fieldInfo, System.EventArgs eventArgs) <0x3124c68 + 0x00054> in <filename unknown>:0 
  at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.DispatchEventAsync (:44300/System.UInt64 eventHandlerId, Microsoft.AspNetCore.Components.RenderTree.EventFieldInfo eventFieldInfo, System.EventArgs eventArgs) <0x31248a0 + 0x00078> in <filename unknown>:0 
  at :44300/Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.ProcessNextDeferredEventAsync () <0x3477c48 + 0x000a6> in <filename unknown>:0 
    at Object.endInvokeDotNetFromJS (blazor.webassembly.js:1)
    at Object.invokeJSFromDotNet (blazor.webassembly.js:1)

Looks like the "navigate away" gets processed before the "blur", so the component has been disposed by the time we process its "blur" event handler.

@SteveSandersonMS SteveSandersonMS added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Apr 27, 2020
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Apr 27, 2020
@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Apr 27, 2020
@mkArtakMSFT mkArtakMSFT removed the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Apr 27, 2020
@MichaelKueh
Copy link

@SteveSandersonMS are there any plans to include this to release 3.2?

@SteveSandersonMS
Copy link
Member Author

Sorry, the deadline for that has already passed. We're really close to the 3.2 release now!

@jameschch
Copy link

jameschch commented May 17, 2020

EDIT: It's not unusual to receive a similar error to this for various events:

blazor.webassembly.js:1 Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '8'.

This can be caused by an error during render which means the element was bound to an event but the error prevented instantiation of the handler.

@jespersh
Copy link

jespersh commented Jun 6, 2020

I tried playing with this call before NavigateTo

await JSRuntime.InvokeVoidAsync("document.activeElement.blur");

but it only worked the first time I saved my form

@vstribrny
Copy link

Please notice there's the same issue also with onfocusout event. I am also facing this issue. The onblur and onfocusout are basically unusable because you never know when user navigates back...

@SteveSandersonMS
Is there a chance to include a fix into some patch for 3.2?

@ghost
Copy link

ghost commented Jul 22, 2020

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.

@mkArtakMSFT
Copy link
Member

@captainsafia the contenteditable issue may be related to this one. Please start from this one. If it is the same cause - great. If not, the other issue may need to be pushed out as it doesn't seem very critical.

@ghost ghost added Done This issue has been fixed and removed Working labels Aug 12, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Sep 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants