Hi René,
Thank you for sharing an extended version of the workaround.
I can confirm that until August, at least, our backlog/short-term planning is filled with items of more priority and demand. Thus, the status here is still unplanned.
Regards,
Hristian Stefanov
Progress Telerik
This is an extended version of the workaround handling both ENTER (primary button) and ESC (base button):
function addKeyDownHandlerForTelerikDialogs() {
document.body.addEventListener("keydown", function (event) {
if (event.key === "Enter") {
if (event.target.classList.contains("k-input-inner") && event.target.closest(".k-dialog")) {
const dialog = event.target.closest(".k-dialog");
const okButton = dialog.querySelector(".k-button-solid-primary");
if (okButton) {
okButton.click();
}
}
}
if (event.key === "Escape") {
if (event.target.classList.contains("k-input-inner") && event.target.closest(".k-dialog")) {
const dialog = event.target.closest(".k-dialog");
const cancelButton = dialog.querySelector(".k-button-solid-base");
if (cancelButton) {
cancelButton.click();
}
}
}
});
}
Still no plans of finally providing this feature?
The ConfirmDelete Dialog in your grid already has the feature of being accepted with ENTER and cancelled with ESC so it should be no rocket science to implement that for all your default dialogs (if you do implement it please don't stop with prompt dialog but do it for Alert and Confirm dialogs as well).
I'm grateful for provided javascript workarounds but providing those should not block the implementation of Feature Requests. As I've mentioned on other occasions as well - I'm using Blazor to get rid of as much javascript as possible and I'm using Telerik components to save as much time as possible.
Regards,
René
Hi Lance,
I have spent time searching for a possible workaround, and I have found the following:
@inject IJSRuntime JSRuntime
<TelerikButton OnClick="@ShowPrompt">Show Prompt</TelerikButton>
@* move this script to an actual script file instead of using this hack *@
<script suppress-error="BL9992">
function addKeyDownHandler() {
document.body.addEventListener("keydown", function (event) {
if (event.key === "Enter") {
if (event.target.classList.contains("k-input-inner") && event.target.closest(".k-dialog")) {
const dialog = event.target.closest(".k-dialog");
const okButton = dialog.querySelector(".k-button");
if (okButton) {
okButton.click();
}
}
}
});
}
</script>
@code {
[CascadingParameter]
private DialogFactory Dialogs { get; set; }
private async Task ShowPrompt()
{
await JSRuntime.InvokeVoidAsync("addKeyDownHandler");
string userInput = await Dialogs.PromptAsync("Enter your answer.");
if (userInput == null)
{
Console.WriteLine("The user will not answer.");
}
else
{
Console.WriteLine($"The user said: {userInput}");
}
}
}
The steps:
Regards,
Hristian Stefanov
Progress Telerik
Hi Marco,
Thank you for showing your interest in the feature request.
I confirm the feature status is still "Unplanned" at this stage. That means no specific time frame has been assigned yet. As soon as we move a task to the short-term backlog, the status will change to "Planned" and most likely an indicative month for releasing it will appear as well.
Regards,
Hristian Stefanov
Progress Telerik
Hello,
any news about this request? Should be something usefull also for our application.
Thanks!