Skip to content

Commit 2da97e5

Browse files
committed
Resolved the OtpInput value mismatch issue for input types text and password.
1 parent 6e12e19 commit 2da97e5

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

maui/src/OtpInput/SfOtpInput.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -937,27 +937,16 @@ static void OnValuePropertyChanged(BindableObject bindable, object oldValue, obj
937937

938938
string newValueStr = newValue?.ToString() ?? string.Empty;
939939
string oldValueStr = oldValue?.ToString() ?? string.Empty;
940+
newValueStr = new string(newValueStr.Where(c => !char.IsControl(c)).ToArray());
941+
oldValueStr = new string(oldValueStr.Where(c => !char.IsControl(c)).ToArray());
940942

941-
if (otpInput.Type == OtpInputType.Number)
943+
if (otpInput.ValueChanged != null)
942944
{
943-
newValueStr = new string(newValueStr.Where(c => !char.IsControl(c)).ToArray());
944-
oldValueStr = new string(oldValueStr.Where(c => !char.IsControl(c)).ToArray());
945+
RaiseValueChangedEvent(otpInput, oldValueStr, newValueStr);
945946
}
946947

947-
if (otpInput.ValueChanged != null)
948-
{
949-
if (otpInput.Type == OtpInputType.Number)
950-
{
951-
RaiseValueChangedEvent(otpInput, oldValueStr, newValueStr);
952-
}
953-
else
954-
{
955-
RaiseValueChangedEvent(otpInput, oldValue?.ToString() ?? string.Empty, newValue?.ToString() ?? string.Empty);
956-
}
957-
}
958-
959-
otpInput.UpdateValue(bindable, newValue?? string.Empty);
960-
}
948+
otpInput.UpdateValue(bindable, newValue ?? string.Empty);
949+
}
961950
}
962951

963952
/// <summary>

0 commit comments

Comments
 (0)