This is a migrated thread and some comments may be shown as answers.

Esc press not closing the angular kendo dialog

1 Answer 936 Views
Dialog
This is a migrated thread and some comments may be shown as answers.
serdar
Top achievements
Rank 1
Veteran
serdar asked on 13 Nov 2020, 01:11 PM

Hi,

I see that if an input in dialog focus(), we can not close the dialog with "Escape" key press.

Is there a general setting that can help me achieve this?

 

--

 

Or is there a way that I can trigger dialog close function with a general event?
document.querySelector(".k-dialog-content input")
                .addEventListener("keydown",function(e){ if(e.key == "Escape") { this.closest(".k-dialog")._wishToClose_(); } });

 


1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 Nov 2020, 07:50 AM

Hello Serdar,

This behavior is expected. The idea is that if the user has focusable elements in his dialog content, we don't want to override possible shortcuts set by him. 

To always close the dialog on escape press, you can create a custom directive which targets the kendo-dialog selector and emit close on escape press. Here's an example. Note that this solution will affect all Dialogs in your application. If you don't want this code to be leaking to other component and possibly cause some undesired behavior, you can handle the escape press inline for every Dialog for which you want this behavior. Here's an example with an escape event listener. 

Let me know if you need further assistance on the topic.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Dialog
Asked by
serdar
Top achievements
Rank 1
Veteran
Answers by
Dimitar
Telerik team
Share this question
or