I created some code to remove any letters that get typed within the input box. When I type in a letter, it gets removed from the UI and variable, however when I type in a letter again, it doesn't get removed from the UI but the code shows it gets removed from the variable. I don't understand why this is happening, I would like it to clear any letters that get typed into the text box automatically, and even have a button that clears it if I want. Here is my code:
@page "/"<input type="text" placeholder="Enter a Value" @bind-value="InputValue" @oninput="HandleInput" /><label for="modal_table_autosearch">Search by name</label><button type="button" @onclick="() => HandleInput(new ChangeEventArgs { Value = null })">Clear Value</button>@code {private string? InputValue { get; set; }private async Task HandleInput(ChangeEventArgs args){ if (args.Value is null) { InputValue = null; return; } var newValue = args.Value?.ToString() ?? string.Empty; InputValue = new string(newValue.Where(char.IsDigit).ToArray()); await Task.Delay(1);}}