Closed ervintuzlic closed 12 months ago
@ervintuzlic By default, ShowLoading
method will disable the button. Refer: https://demos.blazorbootstrap.com/buttons#show-hide-loading-spinner
In your case, you want to disable the button based on the increment. So, do not use Disabled
parameter here. Instead use clickMeButton.Disabled = currentCount > 3;
.
<p role="status">Current count: @currentCount</p>
<Button @ref="clickMeButton" Type="ButtonType.Button" Outline="true" @onclick="IncrementCountAsync" Color="ButtonColor.Primary">Click me</Button>
@code {
private Button? clickMeButton;
private int currentCount = 0;
private async Task IncrementCountAsync() // do not use async void
{
clickMeButton?.ShowLoading("Button is loading but is enabled");
await Task.Delay(5000); // API call
currentCount++;
clickMeButton?.HideLoading();
clickMeButton.Disabled = currentCount > 3;
}
}
Demo:
Description: If button has parameter Disabled="@SomeCondition" on it it will not disable it when ShowLoading method is called.
Code to test:
Expected Behavior: It should be disabled no matter what condition in Parameter Disabled is set when ShowLoading is called.
Versions: BlazorBootstrap: On main project version is 1.8.3 but I tested it on the latest it still has problem .NET Version: .NET 7