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 EventCallbacks are not invoked with apps using .NET 8 template #2355

Open
Tracked by #1667
epetersoni opened this issue Aug 26, 2024 · 3 comments
Open
Tracked by #1667
Assignees
Labels
bug Something isn't working

Comments

@epetersoni
Copy link
Contributor

🐛 Bug Report

Our app was initially created with the Blazor Server App .NET 7 template in VisualStudio. We recently followed the guide to update it to the .NET 8 Blazor Web App template.

It looks like at least some Nimble EventCallbacks are now not getting invoked. Two examples are the NimbleBanner OpenChanged, and the NimbleMenuButton Toggle.

💻 Repro or Code Sample

  • Use VisualStudio to create a new Blazor Web App using the .NET 8 template.
  • Add the NimbleBlazor package (18.0.0 is currently the latest) and required Nimble script / fonts.
  • Put a NimbleBanner component with an OpenChanged callback on a page, and with Open="true".
  • Put anything in the callback method implementation so you can tell when it's invoked.
  • Run the app and dismiss the banner.
  • The callback is not invoked.
  • If you follow the same instructions, but use the Blazor Server App template with .NET 6 or .NET 7, then the callback is invoked.

🤔 Expected Behavior

The EventCallback should get invoked.

😯 Current Behavior

The EventCallback is not invoked.

💁 Possible Solution

Official Nimble .NET 8 support. I'm not sure exactly what difference is causing the behavior change.

🔦 Context

Since updating our app to use the .NET 8 template, a few pieces of functionality that were relying on callbacks are now not working.

We didn't have a specific reason for updating to the .NET 8 template, so we'll need to evaluate what all the callback-related bugs are and whether we should revert the update and / or wait for fixes to this bug.

🌍 Your Environment

  • OS & Device: Windows PC
  • Browser: any
@epetersoni epetersoni added bug Something isn't working triage New issue that needs to be reviewed labels Aug 26, 2024
@ni ni deleted a comment Aug 26, 2024
@jattasNI jattasNI mentioned this issue Aug 26, 2024
11 tasks
@jattasNI
Copy link
Contributor

@epetersoni could you attach a zip of the the .NET 8 you used to reproduce this?

I added this issue as acceptance criteria under #1667 so we'll plan to tackle it as part of that (presumably before .NET 6 goes out of support).

@epetersoni
Copy link
Contributor Author

@jattasNI
net8_no_nimble_callback.zip

@m-akinc m-akinc removed the triage New issue that needs to be reviewed label Aug 27, 2024
@msmithNI msmithNI self-assigned this Sep 12, 2024
@msmithNI
Copy link
Contributor

@epetersoni It looks like this is due to the changes to the Blazor startup process and JS initializers for .NET 8.

NimbleBlazor relies on the afterStarted callback which is now a "classic"/deprecated initializer, which is not called by default.
Blazor provides a way to opt back into the classic initialization behavior, and that looks like a workaround to this issue:

    <script src="_framework/blazor.web.js" autostart="false"></script>
    <script src="_content/NimbleBlazor/nimble-components/all-components-bundle.min.js"></script>
    <script>
        Blazor.start({ enableClassicInitializers: true });
    </script>

However, that Microsoft page states "However, legacy initializer execution is unpredictable."

BlazorEventCallbacks.zip

Once we update Nimble Blazor to target .NET 8, we'll update our JS initialization code to use the new methods, so it's probably best to wait for that. (HLD for that work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

4 participants