Closed
Description
This is an odd one and I thought I found the answer in Microsoft's page life cycle, but I was wrong.
What's happening is on a page where the user can enter a provider number and click a Submit button to search for that number. Enter the number and click Submit to search, right? Nope - you have to click Submit twice. Here's the Mudblazor code:
<MudItem xs="10" md="10" lg="10">
<AutoComplete id="AutoCompleteProviderNumber"
T="string" Label="Provider Number" SearchFunc="@SearchProviderNumbers"
@bind-Value="@model.ProviderNumber" For="@() => model.ProviderNumber)"
InputProps="new InputType { OnInput = HandleInput }"
AutoFocus="true" Adornment="@Icons.Material.Filled.Search"
AdornmentColor="Color.Primary"
</AutoComplete>
</MudItem>
<MudItem xs="2" md="2" lg="2">
<ActionButton id=MudButtonSearch"
ButtonType="ButtonType.Submit"
Disabled=@(!context.Validate() || model.ProviderNumber == null)">
Search
</ActionButton>
</MudItem>
...and then the C# code:
private async Task<IEnumerable<string>> SearchProviderNumbers(string providerNumber, CancellationToken token)
{
if (string.IsNullOrEmpty(providerNumber))
return new string[0];
DTO.Tra.ProviderSearchData temp = new();
var accessTokenProvider = await TokenProvider.RequestAccessToken();
TraApi traapi = new TraApi(accessTokenProvider, Configuration);
var dtoConfig = await traApi,ProviderNumbersSearch(providerNumber);
var result = (IEnumerable<string>)dtoConfig.ProviderNumbersSearchData
.Where(x => x.StartsWith(providerNumber, StringComparison.InvariantCultureIgnoreCase))
.ToList();
return result;
}
Nothing jumps out at me as to why the submit button has to clicked twice. Do you folks see what is wrong here?