Skip to content

Commit 01c4384

Browse files
committed
refactor: 修复布尔值时不触发 OnStateChanged 回调问题
1 parent ccd3bdb commit 01c4384

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/BootstrapBlazor/Components/Checkbox/Checkbox.razor.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,23 @@ private async Task<bool> InternalStateChanged(CheckboxState state)
215215
if (IsBoolean)
216216
{
217217
CurrentValue = (TValue)(object)(state == CheckboxState.Checked);
218-
}
219218

220-
if (State != state)
221-
{
222-
State = state;
223-
if (StateChanged.HasDelegate)
219+
if (ValueChanged.HasDelegate)
224220
{
225-
await StateChanged.InvokeAsync(State);
226221
ret = false;
227222
}
223+
}
228224

229-
if (OnStateChanged != null)
230-
{
231-
await OnStateChanged(State, Value);
232-
}
225+
State = state;
226+
if (StateChanged.HasDelegate)
227+
{
228+
await StateChanged.InvokeAsync(State);
229+
ret = false;
230+
}
231+
232+
if (OnStateChanged != null)
233+
{
234+
await OnStateChanged(State, Value);
233235
}
234236
return ret;
235237
}

0 commit comments

Comments
 (0)