Completed
Last Updated: 12 Sep 2025 09:03 by ADMIN
Release 2025 Q3 (Aug)
Miroslav
Created on: 26 Jul 2023 07:00
Category: Dialog
Type: Bug Report
6
Esc key in TelerikDialog does not close the dialog in some cases

Hello I want to close a TelerikDialog using Esc key and this does not work sometimes. Run this REPL snippet please https://blazorrepl.telerik.com/cnYrwUYq54FZ70xP17. Click into dialog title for instance and press Esc key. Nothing happens.

Very thanks.

Miroslav

  
5 comments
ADMIN
Tsvetomir
Posted on: 12 Sep 2025 09:03

Hello Miroslav,

Thank you for coming back with feedback related to the provided KB article.

To achieve the same behavior with the Dialog title, use the same approach as the one for the content. Below I'm sharing an update code snippet, that showcase the result. I will make sure the update the KB article accordingly.

<TelerikDialog @bind-Visible="@DialogVisible"
               Width="500px"
               Height="300px"
               Class="focusable-content">
    <DialogTitle>
        <div tabindex="0" class="dialog-wrapper">
            Focusable Title
        </div>
    </DialogTitle>
    <DialogContent>
        <div tabindex="0" class="dialog-wrapper">
            <p>Click anywhere in this content area, then press ESC to close the dialog.</p>
        </div>
    </DialogContent>
    <DialogButtons>
        <TelerikButton OnClick="@CloseDialog" ThemeColor="@ThemeConstants.Button.ThemeColor.Primary">Close</TelerikButton>
    </DialogButtons>
</TelerikDialog>

<TelerikButton OnClick="@OpenDialog">Open Dialog</TelerikButton>

<style>
    /* Remove default Dialog content padding to let wrapper handle it */
    .focusable-content .k-dialog-content {
        padding: 0;
    }

    .focusable-content .k-dialog-titlebar {
        padding: 0;
    }

    .focusable-content .k-dialog-titlebar-actions {
        padding-block: var(--kendo-spacing-3, 0.75rem);
        padding-inline: var(--kendo-spacing-4, 1rem);
    }

    /* Focusable wrapper that fills the entire Dialog content area */
    .focusable-content .dialog-wrapper {
        padding: 1rem;
        outline: none;
        height: 100%;
        box-sizing: border-box;
        transition: background-color 0.2s ease;
    }

        /* Optional visual indication when the wrapper is focused */
        /* .focusable-content .dialog-wrapper:focus-within {
            background-color: rgba(0, 123, 255, 0.05);
        } */
</style>

@code {
    private bool DialogVisible { get; set; } = true;
    private string SampleText { get; set; } = string.Empty;

    private void OpenDialog()
    {
        DialogVisible = true;
    }

    private void CloseDialog()
    {
        DialogVisible = false;
    }
}

Regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Miroslav
Posted on: 08 Sep 2025 10:44

Hello,

thank you for the information. The workaround works fine in case of clicking into dialog's content but not for the dialog title. 

How to solve this matter please?

Thank you.

Miroslav

ADMIN
Tsvetomir
Posted on: 05 Sep 2025 12:27

Hello Miroslav,

After e recent review of the reported bug with the team, it was decided to retain the current behavior due to nature of how clicking on a non-focusable elements works. In this case, the Dialog content is a non-focusable element. Clicking it move the focus to the body, because the browser defaults to document.body as the fallback focus target. As a consequence of that, keydown event is not invoked for the Dialog component, which prevents it from closing on Esc key press.

Instead of doing any changes within the source code of the Dialog component, we have created a KB article that demonstrates an approach how to handle such a scenarios: How to Close the Dialog on ESC When its Content is Focused.

Refer to it and let us know if the result aligns with your expectations.

Regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Miroslav
Posted on: 01 Sep 2025 10:18

Hello,

the issue is back. Can you check that please?

Very thanks.

Miroslav

ADMIN
Georgi
Posted on: 02 Aug 2023 06:26

Hi, Miroslav,

Thank you for bringing this situation to our attention. I have confirmed this is a defect on our side. A bug has been logged in our portal.

Additionally, as a small gesture of gratitude for the reported problem, I added Telerik points to your account. 

Regards,
Georgi
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!