-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
With Blazor wasm template projet.
Set counter page like that :
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
[Parameter]
public int currentCount { get; set; } = 0;
// Comment this parameter to observe the difference in behavior
[Parameter]
[SupplyParameterFromQuery(Name = "ko-param")]
public string[]? KoParam { get; set; }
[Parameter]
[SupplyParameterFromQuery(Name = "ok-param")]
public string? OkParam { get; set; }
private void IncrementCount() => currentCount++;
protected override void OnParametersSet()
{
// Add breakpoint
Console.WriteLine("OnParametersSet");
base.OnParametersSet();
}
}
And MainLayout like that :
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
<button @onclick=OnClick>Test</button>
<span class="mx-2">@DateTime.Now</span>
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
@code {
void OnClick() => StateHasChanged();
}
You need to click the test button with and without the string[] parameter.
- If the KoParam parameter is commented, OnParametersSet is not called when I click the Test button. This is what I consider the normal behavior.
- If the KoParam parameter is uncommented, OnParametersSet is called when I click the Test button. In my opinion, this is a malfunction.
Expected Behavior
The expected behavior is that when I use arrays in SupplyParameterFromQuery, the OnParametersSet event should not be called more than necessary
Steps To Reproduce
https://github.com/ggregg/blazor_SupplyParameterFromQuery_bug.git
Exceptions (if any)
No response
.NET Version
7.0.402
Anything else?
SDK .NET :
Version: 7.0.402
Commit: 791db8e2d8
Environnement d'exécution :
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.402\
Host:
Version: 7.0.12
Architecture: x64
Commit: 4a824ef37c
.NET SDKs installed:
2.2.207 [C:\Program Files\dotnet\sdk]
7.0.302 [C:\Program Files\dotnet\sdk]
7.0.402 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download