Skip to content

Buttons: Fix exception doesn't flow to ErrorBoundary.#8369

Merged
ScarletKuro merged 4 commits intoMudBlazor:devfrom
ScarletKuro:eventutil_fix
Mar 15, 2024
Merged

Buttons: Fix exception doesn't flow to ErrorBoundary.#8369
ScarletKuro merged 4 commits intoMudBlazor:devfrom
ScarletKuro:eventutil_fix

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Mar 14, 2024

Description

Fixes: #8365
See: #8365 (comment) and dotnet/aspnetcore#54543
PR that introduced regression: #8203

How Has This Been Tested?

New unit tests for MudButton / MudFab / MudIconButton that check that ErrorBoundary is now working for button.
Also checked on @danielchalmers repro https://github.com/danielchalmers/ScrollToTopBeforeNavigate that the old behaviour with scrolling to top is not back with this change

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Mar 14, 2024
@ScarletKuro ScarletKuro changed the title EventUtil: Exception doesn't flow to ErrorBoundary. EventUtil: Fix exception doesn't flow to ErrorBoundary. Mar 14, 2024
@ScarletKuro ScarletKuro reopened this Mar 14, 2024
@ScarletKuro ScarletKuro changed the title EventUtil: Fix exception doesn't flow to ErrorBoundary. Buttons: Fix exception doesn't flow to ErrorBoundary. Mar 14, 2024
@ScarletKuro ScarletKuro requested a review from henon March 14, 2024 23:09
@codecov
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.72%. Comparing base (bd89de1) to head (e63cbbf).
Report is 4 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #8369   +/-   ##
=======================================
  Coverage   88.72%   88.72%           
=======================================
  Files         407      407           
  Lines       12184    12196   +12     
  Branches     2429     2430    +1     
=======================================
+ Hits        10810    10821   +11     
  Misses        849      849           
- Partials      525      526    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Mar 14, 2024

@henon @danielchalmers I think we have no other choice but use this compomise with

public abstract class XXX : MudComponentBase, IHandleEvent
{
    Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object? arg) => callback.InvokeAsync(arg);
}

if we want this to be fixed #8365 and not come back to this issue #8151

That's the only combination to be working. Luckily the MudButton / MudFab / MudIconButton only have single EventCallback which is OnClick so it's fine to disable all re-renders of EventCallback within those components.

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Mar 14, 2024

We need to check if MudAlert, MudChip, MudLink, MidMenuItem, MudNavLink, MudScrollToTop, MudSnackbarElement got the same problem after #8281, or it's just the buttons in case it's somehow related to MudElement?

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Mar 14, 2024

We need to check if MudAlert, MudChip, MudLink, MudMenuItem, MudNavLink, MudScrollToTop, MudSnackbarElement got the same problem after #8281, or it's just the buttons in case it's somehow related to MudElement?

They are affected 😥 Removing AsNonRenderingEventHandler makes it back to normal...
We might need to partially revert #8281 and just leave the fixed tests and it will be just buttons from this PR.

@danielchalmers
Copy link
Member

God that's depressing 😭 and such an unpleasant workaround. It was a good optimization too

MudMenuItem EventUtil.AsNonRenderingEventHandler<TouchEventArgs>(OnTouchHandler) was important to my app. Is it just not feasible with this new approach?

When are you targeting a new release? Is it possible to hold off until MS has an answer? They're usually pretty quick

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Mar 15, 2024

Is it just not feasible with this new approach?

I couldn't make it work with EventUtil no matter how and what I tried.

MudMenuItem

Well, technically we could add the IHandleEvent.HandleEventAsync to it too, as it has only single eventcallback that doesn't require re-render.

When are you targeting a new release? Is it possible to hold off until MS has an answer? They're usually pretty quick

I haven't yet reverted anything tho, @henon will have to decide what to do with this and about the release too.
But in general I'd say that ErrorBoundary is more important that the scroll issue.

@henon
Copy link
Contributor

henon commented Mar 15, 2024

@ScarletKuro We'll revert the problematic changes for now, or use the workaround you have found, whichever appropriate per component. Reverting has proven to be a good solution in the past because otherwise we are drowned in issues and questions on discord and we can't know when microsoft will fix the bug.

So is this PR ready to merge?

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Mar 15, 2024

So is this PR ready to merge?

I will fix the typo tonight after work then merge this PR.
Then create another PR with reverting the #8281 partially and apply the workaround where applicable.

@ScarletKuro ScarletKuro merged commit fd8c4b8 into MudBlazor:dev Mar 15, 2024
@ScarletKuro ScarletKuro deleted the eventutil_fix branch March 15, 2024 16:02
@ScarletKuro
Copy link
Member Author

@danielchalmers
Copy link
Member

Unfortunate but let me know if I can help to get things working again. Thanks for all the work on managing this stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudButton: ErrorBoundary not working after upgrade to 6.17

3 participants