-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Force full reload on popstate #54877
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
2 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
28 changes: 28 additions & 0 deletions
28
src/Components/test/E2ETest/Tests/GlobalInteractivityTest.cs
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,28 @@ | ||
using Components.TestServer.RazorComponents; | ||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; | ||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; | ||
using Microsoft.AspNetCore.E2ETesting; | ||
using OpenQA.Selenium; | ||
using TestServer; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.AspNetCore.Components.E2ETests.Tests; | ||
|
||
public class GlobalInteractivityTest( | ||
BrowserFixture browserFixture, | ||
BasicTestAppServerSiteFixture<RazorComponentEndpointsStartup<GlobalInteractivityApp>> serverFixture, | ||
ITestOutputHelper output) | ||
: ServerTestBase<BasicTestAppServerSiteFixture<RazorComponentEndpointsStartup<GlobalInteractivityApp>>>(browserFixture, serverFixture, output) | ||
{ | ||
[Fact] | ||
public void CanFindStaticallyRenderedPageAfterClickingBrowserBackButtonOnDynamicallyRenderedPage() | ||
{ | ||
Navigate("/subdir/static"); | ||
|
||
Browser.Click(By.CssSelector("a[href=dynamic]")); | ||
Browser.Navigate().Back(); | ||
|
||
var heading = Browser.Exists(By.TagName("h1")); | ||
Browser.Equal("Statically Rendered", () => heading.Text); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...onents/test/testassets/Components.TestServer/RazorComponents/GlobalInteractivityApp.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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<base href="/subdir/" /> | ||
|
||
<HeadOutlet /> | ||
</head> | ||
|
||
<body> | ||
<Components.WasmMinimal.Routes @rendermode="@RenderModeForPage" /> | ||
<script src="_framework/blazor.web.js" autostart="false"></script> | ||
<script> | ||
Blazor.start({ | ||
webAssembly: { | ||
loadBootResource: (type, name, defaultUri, integrity) => `WasmMinimal/_framework/${name}` | ||
} | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> | ||
|
||
|
||
@code { | ||
[CascadingParameter] | ||
private HttpContext HttpContext { get; set; } = default!; | ||
|
||
// Statically render pages in the "/Account" subdirectory like we do in the Blazor Web template with Individaul auth. | ||
private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/static") | ||
? null | ||
: RenderMode.InteractiveAuto; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Static.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,8 @@ | ||
@page "/static" | ||
|
||
@* This should be statically rendered by GlobalInteractivityApp. *@ | ||
<h1>Statically Rendered</h1> | ||
|
||
<ul> | ||
<li><NavLink href="dynamic">Dynamic page</NavLink></li> | ||
</ul> |
13 changes: 13 additions & 0 deletions
13
src/Components/test/testassets/Components.WasmMinimal/Pages/Dynamic.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,13 @@ | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
|
||
@rendermode RenderMode.InteractiveWebAssembly | ||
|
||
@page "/dynamic" | ||
|
||
<h1>Dynamically Rendered</h1> | ||
|
||
<ul> | ||
<li><NavLink href="static">Static page</NavLink></li> | ||
<li><NavLink href="persist-wasm-state">Another dynamic page</NavLink></li> | ||
</ul> |
9 changes: 9 additions & 0 deletions
9
src/Components/test/testassets/Components.WasmMinimal/Routes.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,9 @@ | ||
@using Microsoft.AspNetCore.Components.Routing | ||
|
||
<Router AppAssembly="@typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound>There's nothing here</NotFound> | ||
</Router> |
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.
Uh oh!
There was an error while loading. Please reload this page.