Skip to content

Default WebAssembly loading progress indicator doesn't apply in Blazor Web template #49056

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

Open
SteveSandersonMS opened this issue Jun 27, 2023 · 3 comments · Fixed by #49801
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-full-stack-web-ui Full stack web UI with Blazor feature-templates Pillar: Complete Blazor Web Priority:1 Work that is critical for the release, but we could probably ship without triaged
Milestone

Comments

@SteveSandersonMS
Copy link
Member

In .NET 7 we added a built-in loading progress indicator for WebAssembly apps.

This continues to work in .NET 8 if you have a WebAssembly standalone project. However if you are using the new Blazor Web template, any WebAssembly components are added via @rendermode, and this will not cause the loading progress indicator to show up, because most of the time you wouldn't want to. You can have any number of small islands of WebAssembly-based UI anywhere, and it will normally be prerendered. And:

  • We don't want to show multiple loading indicators
  • We don't want to discard the prerendered content while the WebAssembly runtime is loading

This issue is just to track that we probably need to update some docs/guidance to avoid implying that people should or can always have a WebAssembly loading progress indicator. Also we might consider having some special new component that does render a loading progress indicator within the new architecture for people who really don't want to prerender their WebAssembly content.

@SteveSandersonMS SteveSandersonMS added area-blazor Includes: Blazor, Razor Components feature-full-stack-web-ui Full stack web UI with Blazor labels Jun 27, 2023
@mkArtakMSFT mkArtakMSFT added this to the 8.0-rc1 milestone Jun 28, 2023
@mkArtakMSFT mkArtakMSFT added the bug This issue describes a behavior which is not expected - a bug. label Jun 28, 2023
@SteveSandersonMS
Copy link
Member Author

SteveSandersonMS commented Jun 30, 2023

Out of scope for .NET 8, but one possible design idea for the future is:

  • When a WebAssembly component is not prerendered, we could always emit some tiny snippet of markup like <blazor-webassembly-placeholder></blazor-webassembly-placeholder>. By default that would produce no visible UI, but people could choose to use CSS to display some kind of "loading" indicator matching that tag name. It might even be sufficient for showing a working progress indicator using our existing CSS variables.
  • When a WebAssembly component is prerendered, we could display it normally, but also, until it actually becomes interactive we could intercept any click or focus events on it and block them, causing it to grey out and overlay a subtle loading indicator.

However if the "auto" mode becomes really mainstream then maybe this would not be a situation in the first place.

@danroth27
Copy link
Member

danroth27 commented Jul 18, 2023

Another use case is upgrading an existing ASP.NET Core hosted Blazor WebAssembly app to .NET 8 and switching from the static index.razor to server-side rendered component (Host.razor). Initially I find it's natural to disable prerendering of the App component when upgrading because many Blazor WebAssembly components aren't set up properly for prerendering (like the default FetchData component, which depends on an HttpClient service). But without prerendering you probably still want the loading indicator.

You can disable prerendering as part of specifying the render mode for the App component, but then you don't have a way to render the loading progress indicator and have it later gets replaced. I can sort of work around this by using the old pattern of registering the App component as a root component with a CSS selector in Program.cs. As long as the HeadOutlet is still setup to use the WebAssembly render mode then blazor.web.js will still load the client app and setup the App component. It feels a bit hacky, but it seems to work.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 3, 2023
@danroth27 danroth27 reopened this Oct 20, 2023
@danroth27
Copy link
Member

Reopening as this can be an issue for users migrating Blazor WebAssembly apps to the Blazor Web App model.

@danroth27 danroth27 modified the milestones: 8.0-rc1, Backlog Oct 20, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT mkArtakMSFT added enhancement This issue represents an ask for new feature or an enhancement to an existing one Priority:1 Work that is critical for the release, but we could probably ship without and removed bug This issue describes a behavior which is not expected - a bug. labels Jan 4, 2024
@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 10 Planning, Backlog Nov 12, 2024
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 feature-full-stack-web-ui Full stack web UI with Blazor feature-templates Pillar: Complete Blazor Web Priority:1 Work that is critical for the release, but we could probably ship without triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants