fix(module: form): cause exception while has no FieldIdentifier (#3717)
* fix(module: form): cause exception while has no FieldIdentifier * clean
This commit is contained in:
Родитель
ebca047a49
Коммит
09cf07439f
|
@ -143,7 +143,8 @@ namespace AntDesign
|
|||
|
||||
OnCurrentValueChange(value);
|
||||
|
||||
if (_isNotifyFieldChanged && (Form?.ValidateOnChange == true))
|
||||
if (_isNotifyFieldChanged && Form?.ValidateOnChange == true
|
||||
&& FieldIdentifier is { Model: not null, FieldName: not null })
|
||||
{
|
||||
EditContext?.NotifyFieldChanged(FieldIdentifier);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
@inherits AntDesignTestBase
|
||||
|
||||
@code {
|
||||
class Model
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public string? RequiredField { get; set; }
|
||||
}
|
||||
Model _model = new();
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Form_regression_test()
|
||||
{
|
||||
Model _model = new();
|
||||
|
||||
//Arrange
|
||||
bool handlerExecuted = false;
|
||||
Action<bool> onChangeHandler = value => { handlerExecuted = true; };
|
||||
var cut = Render(@<Form Model="@_model" ValidateOnChange="true"><Switch OnChange="onChangeHandler" /></Form>);
|
||||
var buttonElement = cut.Find("button");
|
||||
//Act
|
||||
buttonElement.Click();
|
||||
//Assert
|
||||
Assert.True(handlerExecuted);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче