You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[release/8.0-rc2] [Blazor] Make auto components prefer the existing render mode (#50851)
# Make auto components prefer the existing render mode
Ensures that if interactive components exist on the page and they all use a single render mode, components with the "Auto" render mode will also use that render mode.
## Description
It's a common requirement for state to be shared between interactive root components. For example, the `<HeadOutlet>` component, which allows updating content in the HTML `<head>`, renders content specified by a `<HeadContent>` component, if it exists. However, this only works if the `<HeadOutlet>` and `<HeadContent>` components use the same interactive render mode.
The Auto render mode lets Blazor select a "best" render mode (either Server or WebAssembly) at runtime, primarily depending on whether Blazor WebAssembly resources are cached in the browser. However, previously it did this without taking into consideration the render mode used by existing components on the page.
For example, suppose a `<HeadOutlet>` with an Auto render mode gets added to the page before WebAssembly resources have been loaded and cached, so it uses Blazor Server. Later, a `<HeadContent>` component, also with an Auto render mode, gets added to the page. But at this point, WebAssembly resources have loaded completely, so the `<HeadContent>` component uses Blazor WebAssembly. In this example, the content in the `<head>` does not update, because the `<HeadOutlet>` and `<HeadContent>` use different render modes.
This PR updates the auto render mode decision making logic to the following:
* If WebAssembly components exist on the page, use WebAssembly
* Otherwise, if Server components exist on the page, use Server
* Otherwise, if WebAssembly resources are cached, use WebAssembly
* Otherwise, use Server
Fixes#50686
## Customer Impact
Medium/high. We've seen multiple reports of the existing behavior causing problems in customer apps, and there isn't a workaround.
## Regression?
- [ ] Yes
- [X] No
This behavior has existed since the Auto render mode was introduced in an earlier .NET 8 preview release.
## Risk
- [ ] High
- [ ] Medium
- [X] Low
This PR is a small change to the Auto mode logic. It's unlikely that customers were already relying on the existing behavior.
## Verification
- [X] Manual (required)
- [X] Automated
## Packaging changes reviewed?
- [ ] Yes
- [ ] No
- [X] N/A
0 commit comments