-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Enable navigation when RenderModeServer #49768
Conversation
...nents.TestServer/RazorComponents/Pages/EnhancedNav/PageWithServerRenderModeCanNavigate.razor
Outdated
Show resolved
Hide resolved
@@ -115,7 +115,7 @@ function navigateToFromDotNet(uri: string, options: NavigationOptions): void { | |||
function navigateToCore(uri: string, options: NavigationOptions, skipLocationChangingCallback = false): void { | |||
const absoluteUri = toAbsoluteUri(uri); | |||
|
|||
if (!options.forceLoad && isWithinBaseUriSpace(absoluteUri)) { | |||
if (!options.forceLoad && isWithinBaseUriSpace(absoluteUri) && hasInteractiveRouter()) { |
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.
Some tests are failing. I'll find another fix
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.
I suspect this might not be a sufficient solution anyway because if it uses performExternalNavigation
then it won't do enhanced navigation. We would still want enhanced navigation in this case. You can trigger that by calling performEnhancedPageLoad
.
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
…onents/Pages/EnhancedNav/PageWithServerRenderModeCanNavigate.razor Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>
…azorComponents/Pages/EnhancedNav/PageWithServerRenderModeCanNavigate.razor" This reverts commit 01ee2e9.
2a8e37e
to
6701e0f
Compare
export function hasProgrammaticEnhancedNavigationHandler(): boolean { | ||
return programmaticEnhancedNavigationHandler !== undefined; | ||
} | ||
|
||
export function attachProgrammaticEnhancedNavigationHandler(handler: typeof programmaticEnhancedNavigationHandler) { | ||
programmaticEnhancedNavigationHandler = handler; | ||
} | ||
|
||
export function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean): void { | ||
if (!programmaticEnhancedNavigationHandler) { | ||
throw new Error('No enhanced programmatic navigation handler has been attached'); | ||
} | ||
|
||
programmaticEnhancedNavigationHandler(absoluteInternalHref, replace); | ||
} |
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 dance is to avoid NavigationEnhancement.ts
and NavigationManager.ts
from importing each other. That way, blazor.server.js
and blazor.webassembly.js
don't pay the cost of SSR features that they don't use.
Here's a summary of how
IMO, the big question mark in the current approach is the decision to not invoke the
The alternative approach would be to invoke navigation events for programmatically initiated navigations. That would mean:
Which behavior do you all think is more preferable? Should we never invoke navigation events when an interactive router isn't present, or should we always invoke navigation events? @SteveSandersonMS's comment here contains some additional rationale regarding why never invoking navigation events is a viable option. |
Note that, no matter which of those approaches we take, this PR might implement everything necessary for #49414. Rather than introducing a new API for an enhanced page refresh, we could recommend that customers do: NavigationManager.NavigateTo(NavigationManager.Uri, replace: true); We could still introduce a helper if we think it would be useful. Something like: NavigationManager.EnhancedRefresh(); |
From offline discussion, it sounds like we're going to:
Therefore, I declare this PR ready for review |
LGTM! |
Enable navigation when RenderModeServer
Fixes #49142