Duplicated
Last Updated: 16 Apr 2025 07:49 by ADMIN
Nathan
Created on: 14 Apr 2025 15:43
Category: UI for Blazor
Type: Feature Request
1
Window and Dialog "CloseOnEsc" Boolean Parameter
I would be very helpful if the Window and Dialog components had a "CloseOnEsc" Boolean Parameter that would control what would happen if the Esc key was pressed while the dialog is visible.
Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
2 comments
ADMIN
Hristian Stefanov
Posted on: 16 Apr 2025 07:49

Hi Nathan,

I discovered an even simpler approach that doesn't require any JavaScript. You can handle the VisibleChanged event only when opening the Window, and then control closing exclusively through a button click. This disables the Escape key behavior.

I've put together an example to demonstrate this approach. Additionally, I've marked the related item as a duplicate of the existing feature request for customizable keyboard shortcuts.

<TelerikWindow Modal="true"
               Visible="@isModalVisible"
               VisibleChanged="@VisibleChangedHandler"
               CloseOnOverlayClick="true">
    <WindowTitle>
        Window Title
    </WindowTitle>
    <WindowContent>
        I am modal, so the page content behind me is not accessible to the user.
    </WindowContent>
    <WindowActions>
        <WindowAction Name="Close" OnClick="@CloseWindow" />
    </WindowActions>
</TelerikWindow>

<TelerikButton OnClick="@( _ => isModalVisible = true )">Open the window</TelerikButton>

@code {
    private bool isModalVisible { get; set; } = true;

    private void VisibleChangedHandler(bool currVisible)
    {
        if (currVisible)
        {
            isModalVisible = currVisible;
        }
    }

    private void CloseWindow()
    {
        isModalVisible = false;
    }
}

Regards,
Hristian Stefanov
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

ADMIN
Hristian Stefanov
Posted on: 16 Apr 2025 06:48

Hi Nathan,

I can confirm that disabling/enabling the Esc key action is easily achievable with a small JavaScript function. Here is an example with a disabled Esc key: REPL link.

Regards,
Hristian Stefanov
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!