MudMenu: Fix PositionAtCursor#10122
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #10122 +/- ##
==========================================
+ Coverage 91.18% 91.23% +0.05%
==========================================
Files 411 411
Lines 12480 12484 +4
Branches 2431 2431
==========================================
+ Hits 11380 11390 +10
+ Misses 556 552 -4
+ Partials 544 542 -2 ☔ View full report in Codecov by Sentry. |
|
I don't know how to make codecov happy. |
Moved set to a private bool that applies static class when it's static position.
|
This also fixes: #8124 |
|
I fixed all the problems etc. But I think using the DataGrid in the upd: anyway, going bed now, its very late and I'm doing more and more typos in the text. P.S. I also noticed it's writing in |
Removed trailing ; as it is a duplicate
@ScarletKuro |
Are we talking about |
|
That invisible menu shouldn't be rendered in the first place |
If I understand what you are saying, all the popovers work that way, inspect a page with a mudselect, mudautocomplete, tooltip, etc find the popover provider element and every popover will be listed there just not visible. The visible ones will have a data-ticks attribute > 0 |
Are we talking about the Popover Provider? Unfortunately, on this screen, I can't tell if it is coming from the provider or not. If it is, then that’s expected and unrelated to this PR, it will list all popovers inside it as invisible with empty content. When (heh, just noticed that the formatting in the file is not correct) This was architected this way long before I joined the team, I only boosted the performance, but the principal is still the same. |
|
looks like what's mentioned isn't from the provider after further research but also it's required. Popover needs a parent to place itself. There's nearly nothing in it, the actual menu is with the provider. |
|
So to summarize the invisible element needs to be there, but clicking it shouldn't cause a crash, I guess. |
|
The invisible element must not:
Currently the menu renders as an empty button. IMHO this button element should not be rendered at all. |
|
I was able to reproduce the issue with this example: There is indeed a hidden clickable element that crashes both server-side and wasm. blazor.web.js:1
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at MudBlazorWebAppAuto.Client.Pages.Counter.<BuildRenderTree>b__0_14(RenderTreeBuilder __builder3)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at MudBlazor.MudMenuItem.<BuildRenderTree>b__53_0(RenderTreeBuilder __builder2)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at MudBlazor.MudListItem`1[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<BuildRenderTree>b__141_3(RenderTreeBuilder __builder3) in C:\Users\KuroPC\source\repos\MudBlazor\src\MudBlazor\Components\List\MudListItem.razor:line 51
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at MudBlazor.MudText.<BuildRenderTree>b__37_0(RenderTreeBuilder __builder2)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at MudBlazor.MudElement.BuildRenderTree(RenderTreeBuilder builder) in C:\Users\KuroPC\source\repos\MudBlazor\src\MudBlazor\Components\Element\MudElement.cs:line 99
at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__7_0(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)When clicking on it, the popover opens BUT this PR is not the cause of the issue. Setting |
|
In fact, it's even reproducible on v7: https://try.mudblazor.com/snippet/wkQolPwMqOAZytWz |
|
Null exception is fixed in #10352 |
Co-authored-by: Artyom M. <[email protected]>



Description
Mudmenu as a Context Menu and in some cases when using PositionAtCursor was not properly setting the position due to the args events relating to the container it's in not necessarily where the popover needed to nest. Our javascript would then jumble that up more and make it near impossible to have consistent behavior. These changes standardize anytime the exact position is known such as args.PageX and args.PageY to not allow javascript to determine position (except flipping behavior). This is accomplished by a class
mud-popover-position-overrideAdditionally added a DataGrid Context Menu example in the Docs section and a MudTable (I don't recommend this, too laggy) and DataGrid example in the UnitTests.Viewer section.
Resolves #3060
Resolves #3854
Resolves #10073
Resolves: #8124
How Has This Been Tested?
Tons of visual tests in first comment
Type of Changes
Checklist
dev).