-
Notifications
You must be signed in to change notification settings - Fork 372
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
fix: FluentRadioGroup crashes inside EditForm if using an explicit EventCallback #1103
Comments
I would like to provide some more information about this issue. I tried creating project like report and got the exception below.
I started searching for the cause at /src/Core/Components/Base/FluentInputBase.cs // file: /src/Core/Components/Base/FluentInputBase.cs
...
internal bool FieldBound => ValueExpression != null || ValueChanged.HasDelegate;
...
protected virtual string? ClassValue
{
get
{
string? fieldClass = FieldBound ? EditContext?.FieldCssClass(FieldIdentifier) : null; // line 258: location of exception
...
}
}
...
public override Task SetParametersAsync(ParameterView parameters)
{
parameters.SetParameterProperties(this);
if (!_hasInitializedParameters)
{
// This is the first run
// Could put this logic in OnInit, but its nice to avoid forcing people who override OnInit to call base.OnInit()
if (ValueExpression is not null)
{
FieldIdentifier = FieldIdentifier.Create(ValueExpression);
}
if (CascadedEditContext != null)
...
_hasInitializedParameters = true;
}
...
}
... Above is the code I want the maintainer to pay attention to. According to the logic of the code if I propose to fix this issue by creating a if (ValueExpression is not null)
{
FieldIdentifier = FieldIdentifier.Create(ValueExpression);
}
else if (ValueChanged.HasDelegate)
{
FieldIdentifier = FieldIdentifier.Create(() => Value);
} I hope the above information will be useful. |
@iotalambda On the user side, you can temporarily provide manual <EditForm Model=@model2>
<FluentRadioGroup TValue=@ItemType Value=@model2.Item
ValueExpression="@(() => model2.Item)"
ValueChanged=@(v => model2.Item = v)>
<FluentRadio Value=@ItemType.Item1></FluentRadio>
<FluentRadio Value=@ItemType.Item2></FluentRadio>
</FluentRadioGroup>
</EditForm> |
Hi La Minh Phuc, |
Yes, put it in |
🐛 Bug Report
FluentRadioGroup crashes when its value is changed. The bug occurs at least inside EditForms when using explicit EventCallbacks.
💻 Repro or Code Sample
dotnet new install Microsoft.FluentUI.AspNetCore.Templates::4.1.1
dotnet new fluentblazor
Counter.razor
contents with this:🤔 Expected Behavior
Changing both FluentRadioGroup values should work.
😯 Current Behavior
The second FluentRadioGroup crashes when changing its value.
The text was updated successfully, but these errors were encountered: