diff --git a/src/Masa.Blazor/Components/OtpInput/MOtpInput.razor.cs b/src/Masa.Blazor/Components/OtpInput/MOtpInput.razor.cs index 6d5d54dcde..5857df10cf 100644 --- a/src/Masa.Blazor/Components/OtpInput/MOtpInput.razor.cs +++ b/src/Masa.Blazor/Components/OtpInput/MOtpInput.razor.cs @@ -92,30 +92,6 @@ protected override async Task OnParametersSetAsync() } #endif - if (_prevValue != Value) - { - Value ??= string.Empty; - var prevValueLength = _prevValue?.Length ?? 0; - var valueLength = Value.Length; - _prevValue = Value; - - for (var i = 0; i < Math.Max(prevValueLength, valueLength); i++) - { - if (i >= _otp.Count) - { - continue; - } - - _otp[i] = i < valueLength ? Value[i].ToString() : string.Empty; - } - - if (Value != ComputedValue) - { - _prevValue = ComputedValue; - await ValueChanged.InvokeAsync(_prevValue); - } - } - if (_prevLength != Length) { _prevLength = Length; @@ -141,6 +117,30 @@ protected override async Task OnParametersSetAsync() } } } + + if (_prevValue != Value) + { + Value ??= string.Empty; + var prevValueLength = _prevValue?.Length ?? 0; + var valueLength = Value.Length; + _prevValue = Value; + + for (var i = 0; i < Math.Max(prevValueLength, valueLength); i++) + { + if (i >= _otp.Count) + { + continue; + } + + _otp[i] = i < valueLength ? Value[i].ToString() : string.Empty; + } + + if (Value != ComputedValue) + { + _prevValue = ComputedValue; + await ValueChanged.InvokeAsync(_prevValue); + } + } } protected override async Task OnAfterRenderAsync(bool firstRender)