Skip to content

Commit c17b088

Browse files
authored
🐛 fix(SLabeledRadioGroup): prevent unnecessary SelectedKeyChanged calls (#780)
* 🐛 fix(SLabeledRadioGroup): prevent unnecessary SelectedKeyChanged calls * update testapp
1 parent 24a709d commit c17b088

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/Masa.Stack.Components/Shared/PureComponents/LabeledRadios/SLabeledRadioGroup.razor

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@
116116

117117
if (item != null)
118118
{
119-
_selectedKey = item.Instance?.Value;
120-
await SelectedKeyChanged(_selectedKey);
119+
var currentKey = item.Instance?.Value;
120+
if (currentKey != _selectedKey)
121+
{
122+
await SelectedKeyChanged(currentKey);
123+
}
121124
}
122125

123126
await CallSlider();

tests/Masa.Stack.Components.Standalone.TestApp/Masa.Stack.Components.Standalone.TestApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>

tests/Masa.Stack.Components.Standalone.TestApp/Pages/_Host.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434

3535
<script src="_framework/blazor.server.js"></script>
3636
<script src="_content/Masa.Blazor/js/masa-blazor.js"></script>
37+
<script src="_content/Masa.Stack.Components/js/components.js"></script>
3738
</body>
3839
</html>

tests/Masa.Stack.Components.Standalone.TestApp/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
using Masa.Stack.Components.JsInterop;
12
using Microsoft.AspNetCore.Components;
23
using Microsoft.AspNetCore.Components.Web;
34

45
var builder = WebApplication.CreateBuilder(args);
56
builder.Services.AddRazorPages();
67
builder.Services.AddServerSideBlazor();
78
builder.Services.AddMasaBlazor();
9+
builder.Services.AddScoped<JsDotNetInvoker>();
810

911
var app = builder.Build();
1012

0 commit comments

Comments
 (0)