-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Support NavigateTo when enhanced nav is disabled #52267
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
Support NavigateTo when enhanced nav is disabled #52267
Conversation
Hi @SteveSandersonMS. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document. |
ca911c2
to
634550a
Compare
@Body | ||
<main> | ||
@Body | ||
</main> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is needed to work around a limitation in the DOM diffing (can't merge two elements of which only one is a LogicalElement). Doesn't affect the validity of the scenario, but doing this allows the E2E test to make stricter and more interesting assertions about element preservation.
// In blazor.web.js, we explicitly recognize the case where you have neither an interactive nor enhanced SSR router | ||
// attached, and then handle Blazor.navigateTo by doing a full page load because that's more useful (issue #51636). | ||
return Blazor._internal.isBlazorWeb ? 'serverside-fullpageload' : 'clientside-router'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we just had a boolean condition "shouldUseClientSideRouting". However that was misleading because there are really three cases (client-side routing, enhanced nav, and neither). By changing this boolean condition to one with all three possibilities, it forces other code to remember and account for the "neither" case.
Hi @SteveSandersonMS. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
More notes for PR reviewers: This is actually going to be an intentional change of behavior going from
For back-compat with .NET 7 upgrades even in this very niche case, I've retained the old behavior on |
Hi @SteveSandersonMS. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed. |
Support NavigateTo when enhanced nav is disabled
Makes the NavigateTo API work even if enhanced nav is disabled via config.
Description
By default, Blazor apps have either enhanced nav or an interactive router . In these default cases, the
NavigateTo
API works correctly.However there's also an obscure way to disable both of these via config. It's niche, but it's supported, so the rest of the system should work with that. Unfortunately
NavigateTo
assumes that either enhanced nav or an interactive router will be enabled and doesn't account for the case when neither is.Fixes #51636
Customer Impact
Without this fix, anyone who uses the
ssr: { disableDomPreservation: true }
config option will be unable to use theNavigateTo
API, as it will do nothing. This behavior isn't desirable.Regression?
No because existing code can't use
ssr: { disableDomPreservation: true }
as the option didn't exist prior to .NET 8.Someone else might argue that it's a regression in the sense that, if you're migrating existing code to use newer .NET 8 patterns (and are using
disableDomPreservation
for some reason, even though you wouldn't normally), your existing uses ofNavigateTo
could stop working. That's not how we normally define "regression" but I'm trying to give the fullest explanation.Risk
The fix explicitly retains the old code path if you're coming from .NET 7 or earlier (i.e., if you are using
blazor.webassembly/server/webview.js
. The fixed code path is only applied inblazor.web.js
, so it should not affect existing apps that are simply moving to thenet8.0
TFM without other code changes.Verification
Packaging changes reviewed?