Various components: Avoid re-renderings from interaction events#8281
Various components: Avoid re-renderings from interaction events#8281henon merged 19 commits intoMudBlazor:devfrom
Conversation
|
@ScarletKuro Thanks for identifying the fix for MudButton in dotnet/aspnetcore#8203! Seemed to do the trick as seen below: Video2.mp4This PR will expand that effort to other controls. I use MudIconButton and MudMenuItem specifically. It hasn't been tested at all and pretty sure it doesn't compile, but I'm waiting to see if the original fix has no side effects, as you mentioned, and if you're interested in seeing the effort continued :) |
Issue described in https://github.com/dotnet/aspnetcore/issues/53863 and for MudBlazor at MudBlazor/MudBlazor#8151. The MudBlazor part was remedied for MudButton with MudBlazor/MudBlazor#8203 in 6.17.0 but MudIconButton and MudMenuItem were not impacted and are awaiting MudBlazor/MudBlazor#8281
|
@mikes-gh I think you reviewed the commit which Daniel made on his own repo/app ;) |
|
@ScarletKuro test is failing with: which could be from the icon buttons? MudBlazor/src/MudBlazor/Components/ColorPicker/MudColorPicker.razor Lines 12 to 21 in 5b3757a |
|
Yes, we unfortunately have a lot of these stale references in the tests. |
|
Yes, this is why I had to do change the ToggleGroupTests.cs |
basically just dialing things back and staying focused on fixing key stale references; less proactive to avoid disrupting the codebase
|
@ScarletKuro @henon Should be ready except for the last failing test: // MenuTests
public async Task OnClickErrorContentCaughtException()
{
var comp = Context.RenderComponent<MenuErrorContenCaughtException>();
await comp.FindAll("button.mud-button-root")[0].ClickAsync(new MouseEventArgs());
comp.FindAll("div.mud-popover-open").Count.Should().Be(1);
comp.FindAll("div.mud-list-item").Count.Should().Be(1);
await comp.FindAll("div.mud-list-item")[0].ClickAsync(new MouseEventArgs());
var mudAlert = comp.FindComponent<MudAlert>();
var text = mudAlert.Find("div.mud-alert-message");
text.InnerHtml.Should().Be("Oh my! We caught an error and handled it!");
}@* MenuErrorContenCaughtException *@
@namespace MudBlazor.UnitTests.TestComponents
<ErrorBoundary>
<ChildContent>
<MudPopoverProvider></MudPopoverProvider>
<MudMenu Label="Open Menu">
<ChildContent>
<MudMenuItem @onclick="@HandleClickAsync">Throw error</MudMenuItem>
</ChildContent>
</MudMenu>
<br/>
</ChildContent>
<ErrorContent>
<MudAlert Severity="Severity.Error">Oh my! We caught an error and handled it!</MudAlert>
</ErrorContent>
</ErrorBoundary>
@code {
public async Task HandleClickAsync()
{
await Task.Delay(100);
throw new Exception("Something went wrong...");
}
}I don't think it's capturing the exception properly due to the async click handler but I could be wrong. Adding a |
mostly just the buttons MenuTests.OnClickErrorContentCaughtException is the only one remaining
|
I'm slightly confused why are we modifying the examples from Docs, they are not related to the Unit test area. Maybe I'm wrong, @henon can correct me.
I will try to look on weekends when I get time, for now I'm busy with other PRs. |
|
Sure, no problem. Badge, Alert, FAB are gone. Chip, ListItem, and NavMenu remain - let me know which you want gone or all of them. |
makes all changes to SelectTests obsolete and revertable also fixes the elusive OnClickErrorContentCaughtException trims down the PR big time. if necessary we can work on list item afterwards but it's better to get the majority through smoothly
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev dotnet/aspnetcore#8281 +/- ##
==========================================
+ Coverage 88.54% 88.64% +0.10%
==========================================
Files 400 407 +7
Lines 12086 12178 +92
Branches 2426 2430 +4
==========================================
+ Hits 10701 10795 +94
+ Misses 858 855 -3
- Partials 527 528 +1 ☔ View full report in Codecov by Sentry. |
|
List item was reverted because the expand toggle wasn't working. Could be looked into further but I might not need it for what I'm doing and seems to have wide-reaching consequences. Fixes the failing test and simplifies the PR through Overlay was reverted as well bc I'm not comfortable with the consequences of that considering a @ScarletKuro PR has been trimmed down and all tests are passing 🎉 |
Issue described in https://github.com/dotnet/aspnetcore/issues/53863 and for MudBlazor at MudBlazor/MudBlazor#8151. The MudBlazor part was remedied for MudButton with MudBlazor/MudBlazor#8203 in 6.17.0 but MudIconButton and MudMenuItem were not impacted and are awaiting MudBlazor/MudBlazor#8281
|
@danielchalmers can you please post screenshots of the new examples? |
The chip has a distinct style when clickable so could be worthy of a showcase. Video2.mp4NavMenuLink now has an OnClick section like Link Video2.mp4You can see a bug in the video where if you click the About link while Settings is collapsed, Settings will open. This is not a regression. |
|
OK, I think we can keep these examples. |
ScarletKuro
left a comment
There was a problem hiding this comment.
@henon this is ready to merge.
|
Thanks @danielchalmers |
…lazor#8281) * Fix extra re-render for more components * Click docs * Avoid stale element references in tests --------- Co-authored-by: Artyom M <[email protected]>
…lazor#8281) * Fix extra re-render for more components * Click docs * Avoid stale element references in tests --------- Co-authored-by: Artyom M <[email protected]>
…lazor#8281) * Fix extra re-render for more components * Click docs * Avoid stale element references in tests --------- Co-authored-by: Artyom M <[email protected]>

Description
Follows up on dotnet/aspnetcore#8203 by making click and touch events non-rendering for other key controls in order to work around the problem described in dotnet/aspnetcore#8151 and dotnet/maui#31944.
How Has This Been Tested?
Existing unit tests were used
Types of changes
Checklist:
dev).