Skip to content

Commit

Permalink
fix: MTextField bind-value reset bug (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin1ee authored May 19, 2022
1 parent efbf63e commit 2325190
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Masa.Blazor/Components/TextField/MTextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected virtual Dictionary<string, object> InputAttrs
Dictionary<string, object> attibutes = new(Attributes)
{
{ "type", Type },
{ "value", _badInput == null ? InputValue : _badInput }
{ "value", _badInput == null ? InternalValue : _badInput }
};

if (Type == "number")
Expand Down Expand Up @@ -625,7 +625,7 @@ public virtual async Task HandleOnBlurAsync(FocusEventArgs args)

if (!EqualityComparer<TValue>.Default.Equals(checkValue, InternalValue))
{
TempValue = checkValue;
InputValue = checkValue;
}

await ChangeValue(true);
Expand All @@ -643,7 +643,7 @@ public virtual async Task HandleOnInputAsync(ChangeEventArgs args)
if (success)
{
_badInput = null;
TempValue = val;
InputValue = val;

if (OnInput.HasDelegate)
{
Expand Down Expand Up @@ -674,7 +674,7 @@ public async Task TextFieldDebounceTimerRun()
{
if (!_compositionInputting)
{
await SetInternalValueAsync(TempValue);
await SetInternalValueAsync(InputValue);

StateHasChanged();
}
Expand Down Expand Up @@ -761,8 +761,6 @@ public virtual async Task HandleOnFocusAsync(FocusEventArgs args)
{
IsFocused = true;

await ChangeValue(true);

if (OnFocus.HasDelegate)
{
await OnFocus.InvokeAsync(args);
Expand Down

0 comments on commit 2325190

Please sign in to comment.