-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
167 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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
...estServer/RazorComponents/Pages/EnhancedNav/PageRenderingComponentWithNullParameter.razor
This file contains 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 @@ | ||
@page "/nav/null-parameter/{mode}" | ||
@using TestContentPackage | ||
|
||
@* https://github.com/dotnet/aspnetcore/issues/52434 *@ | ||
|
||
<h1>Page rendering component with null parameter</h1> | ||
|
||
@if (Mode == "server") | ||
{ | ||
<ComponentAcceptingNullParameter @rendermode="RenderMode.InteractiveServer" Value="@null" /> | ||
} | ||
else if (Mode == "wasm") | ||
{ | ||
<ComponentAcceptingNullParameter @rendermode="RenderMode.InteractiveWebAssembly" Value="@null" /> | ||
} | ||
else | ||
{ | ||
<p>Expected a render mode of 'server' or 'wasm', but got '@Mode'.</p> | ||
} | ||
|
||
@code { | ||
[Parameter] | ||
public string? Mode { get; set; } | ||
} |
This file contains 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
52 changes: 52 additions & 0 deletions
52
src/Components/test/testassets/TestContentPackage/ComponentAcceptingNullParameter.razor
This file contains 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,52 @@ | ||
@implements IDisposable | ||
@inject NavigationManager NavigationManager | ||
@using Microsoft.AspNetCore.Components.Routing | ||
|
||
<p>Value: @(Value ?? "(null)")</p> | ||
|
||
@if (_interactive) | ||
{ | ||
<button id="button-increment" @onclick="Increment">Count: <span id="current-count">@_count</span></button> | ||
<button id="button-refresh" @onclick="Refresh">Refresh</button> | ||
<p>Location changed count: <span id="location-changed-count">@_locationChangedCount</span></p> | ||
} | ||
|
||
@code { | ||
private bool _interactive; | ||
private int _count; | ||
private int _locationChangedCount; | ||
|
||
[Parameter] | ||
public string Value { get; set; } | ||
|
||
protected override void OnAfterRender(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
NavigationManager.LocationChanged += OnLocationChanged; | ||
_interactive = true; | ||
StateHasChanged(); | ||
} | ||
} | ||
|
||
private void OnLocationChanged(object sender, LocationChangedEventArgs e) | ||
{ | ||
_locationChangedCount++; | ||
StateHasChanged(); | ||
} | ||
|
||
private void Increment() | ||
{ | ||
_count++; | ||
} | ||
|
||
private void Refresh() | ||
{ | ||
NavigationManager.Refresh(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
NavigationManager.LocationChanged -= OnLocationChanged; | ||
} | ||
} |