In some cases I have need of a button with additional options.
These options are typically put in a drop down associated to the button.
A split button makes this natural.
In this mode the user can click on the button itself or expand the dropdown and click on one of the options inside.
In some cases I have need of a true/false or on/off selection.
Currently I am doing that through drop down options however it would be more natural in some cases to have a switch style button.
It would help me with my testing mostly.
===
ADMIN EDIT
You may also want to vote for and follow this request for adding Id property to all components
https://feedback.telerik.com/blazor/1495842-add-id-parameter-on-all-blazor-components
If you need this attribute for testing only, you may find interesting this request: https://feedback.telerik.com/blazor/1513117-translators-for-selenium-testing-for-the-telerik-ui-for-blazor-components. If so, Vote for it and Follow it so we can know there is interest, and so you can get status updates.
===
It lets the browser "click" the button without requiring initial focus first.
The following can be a workaround for the time being:
<TelerikButton OnClick="@OnSave" Primary="true">
Save<span accesskey="S"></span>
</TelerikButton>
@code{
async Task OnSave()
{
Console.WriteLine("saved");
}
}
Consider the following Blazor markup:
This will be rendered as a disabled HTML button with the class k-disabled. If a malicious user edits the DOM to remove the disabled attribute and said class, the button will become enabled. If the user then clicks the button, the registered OnClick EventCallback gets executed, even though Enabled is set to false.
Telerik-REPL link https://blazorrepl.telerik.com/QcumwJPA47xzAake54
Here is a JavaScript function that can be used to enable the disabled button (please make sure to use the correct JavaScript context when using it inside the Browsers DevTools):
}
We are not sure if this can be considered a bug or if the registered OnClick EventCallback is supposed to make sure the button is enabled. It would, however, make sense for a Blazor Server environment if the TelerikButton component would check its Enabled state before triggering the EventCallback.