-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Enable navigation when RenderModeServer #49768
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df7b03d
enable navigation render mode server
surayya-MS 6b4ce9f
Update src/Components/test/testassets/Components.TestServer/RazorComp…
surayya-MS ebe7e09
Revert "Update src/Components/test/testassets/Components.TestServer/R…
surayya-MS 6701e0f
If no interactive router, do enhanced navigation
MackinnonBuck 245c01e
More tests + fixes
MackinnonBuck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...tServer/RazorComponents/Pages/EnhancedNav/PageWithInteractiveComponentsThatNavigate.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@page "/nav/interactive-component-navigation/{renderMode}" | ||
@using TestContentPackage; | ||
@inject NavigationManager Nav | ||
|
||
@{ | ||
_renderId++; | ||
} | ||
|
||
<h1>Page with interactive components that navigate</h1> | ||
|
||
<p> | ||
SSR render ID: <span id="render-id">@_renderId</span> | ||
</p> | ||
|
||
@if (_renderMode is not null) | ||
{ | ||
<InteractiveNavigationComponent @rendermode="@_renderMode" /> | ||
} | ||
else | ||
{ | ||
<text>Invalid render mode "@RenderMode"</text> | ||
} | ||
|
||
@code { | ||
private IComponentRenderMode? _renderMode; | ||
private static int _renderId; | ||
|
||
[Parameter] | ||
public string RenderMode { get; set; } | ||
|
||
protected override void OnInitialized() | ||
{ | ||
if (string.Equals("server", RenderMode, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
_renderMode = new ServerRenderMode(prerender: false); | ||
} | ||
else if (string.Equals("webassembly", RenderMode, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
_renderMode = new WebAssemblyRenderMode(prerender: false); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Components/test/testassets/TestContentPackage/InteractiveNavigationComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@inject NavigationManager Navigation | ||
|
||
<button type="button" id="navigate-to-another-page" @onclick="NavigateToAnotherPage">Navigate to another page</button> | ||
<br /> | ||
<button type="button" id="perform-enhanced-refresh" @onclick="PerformEnhancedRefresh">Perform enhanced refresh</button> | ||
<br /> | ||
<button type="button" id="perform-page-reload" @onclick="PerformPageReload">Perform page reload</button> | ||
|
||
@code { | ||
private void NavigateToAnotherPage() | ||
{ | ||
Navigation.NavigateTo("nav"); | ||
} | ||
|
||
private void PerformEnhancedRefresh() | ||
{ | ||
Navigation.NavigateTo(Navigation.Uri, replace: true); | ||
} | ||
|
||
private void PerformPageReload() | ||
{ | ||
Navigation.NavigateTo(Navigation.Uri, forceLoad: true, replace: true); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andNavigationManager.ts
from importing each other. That way,blazor.server.js
andblazor.webassembly.js
don't pay the cost of SSR features that they don't use.