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

[Blazor] add support for the onmouseenter and onmouseleave dom events in components #13104

Closed
ghidello opened this issue Aug 13, 2019 · 5 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one
Milestone

Comments

@ghidello
Copy link
Contributor

Until preview 7, I could bind an handler to the onmouseenter and onmouseleave events using a syntax similar to onmouseenter="@MouseEnter". Now this syntax is not working anymore and the syntax @onmouseenter="MouseEnter" leads to this runtime error in Blazor Wasm:

Microsoft.JSInterop.JSException: Failed to execute 'setAttribute' on 'Element': '@onmouseenter' is not a valid attribute name.

Describe the solution you'd like

Add the onmouseenter and onmouseleave to the list of the supported mouse events (I don't know if it's just a matter of adding them to the EventHandlers.cs) class.

Additional context

I'm using those events on a div containing a number of other elements. Using the onmouseover and onmouseout events (which are supported) can't be a solution because they're fired when crossing the boudaries of the external div but also whenever the mouse crosses the border of any of the internal elements causing the events to be fired multiple times.

ghidello added a commit to sotsera/sotsera.blazor.toaster that referenced this issue Aug 13, 2019
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Aug 14, 2019
@mkArtakMSFT mkArtakMSFT added this to the 5.0.0 milestone Aug 14, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @ghidello.
You can add a new class called EventHandlers and add define the needed mappings for these event handlers in there (similar to how it's done in the EventHandlers.cs) and it should just work.

@julienGrd
Copy link

I had the same problem and can confirm it works with the workaround of mkArtakMSFT

@ghidello
Copy link
Contributor Author

Thanks a lot @mkArtakMSFT
I've not figured out how but it's working! Thanks again!

@ghidello
Copy link
Contributor Author

Notifying also @miroslavp who asked about the same events on #5501

@royzhang666
Copy link

royzhang666 commented Aug 26, 2019

thanks @mkArtakMSFT , the workaround worked. May I know when can these two events added officially to the EventHandlers.cs? Appreciate your help.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

4 participants