Skip to content

Commit

Permalink
enable navigation render mode server
Browse files Browse the repository at this point in the history
  • Loading branch information
surayya-MS committed Aug 1, 2023
1 parent c64d745 commit 66515e3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Components/Web.JS/src/Services/NavigationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
performInternalNavigation(absoluteUri, false, options.replaceHistoryEntry, options.historyEntryState, skipLocationChangingCallback);
} else {
// For external navigation, we work in terms of the originally-supplied uri string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ public void CanFollowAsynchronousExternalRedirectionWhileStreaming()
Browser.Contains("microsoft.com", () => Browser.Url);
}

[Fact]
public void RenderModeServerCanNavigateToAnotherPage()
{
Navigate($"{ServerPathBase}/nav");
Browser.Equal("Hello", () => Browser.Exists(By.TagName("h1")).Text);

Browser.Exists(By.TagName("nav")).FindElement(By.LinkText("Render mode Server navigation")).Click();
Browser.Equal("Render mode Server can navigate", () => Browser.Exists(By.TagName("h1")).Text);

Browser.Exists(By.Id("navigate")).Click();

Browser.Equal("Hello", () => Browser.Exists(By.TagName("h1")).Text);
Assert.EndsWith("/nav", Browser.Url);
}

private long BrowserScrollY
{
get => Convert.ToInt64(((IJavaScriptExecutor)Browser).ExecuteScript("return window.scrollY"), CultureInfo.CurrentCulture);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@page "/nav/render-mode-server-can-navigate"
@inject NavigationManager Nav
@attribute [RenderModeServer]
<PageTitle>Render mode Server can navigate</PageTitle>

<h1>Render mode Server can navigate</h1>

<button @onclick="Navigate" id="navigate">Navigate</button>

@code {
void Navigate()
{
Nav.NavigateTo("nav");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NavLink href="nav/do-redirection-while-streaming">Redirect while streaming</NavLink> |
<NavLink href="nav/do-redirection-while-streaming?destination=https://microsoft.com">Redirect external while streaming</NavLink> |
<NavLink href="nav/throw-while-streaming">Error while streaming</NavLink>
<NavLink href="nav/render-mode-server-can-navigate">Render mode Server navigation</NavLink>
</nav>
<hr/>
@Body

0 comments on commit 66515e3

Please sign in to comment.