You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: knowledge-base/dialog-close-on-esc.md
+21-4Lines changed: 21 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ This knowledge base article answers to the following questions:
13
13
14
14
* How to make Dialog responsive to keyboard events when content is clicked?
15
15
* Why doesn't ESC key work after clicking inside Dialog content?
16
+
* How can I make the Dialog close with the ESC key after the title has been clicked?
16
17
* How to maintain keyboard functionality in Dialog after focus changes?
17
18
18
19
When you click or focus inside the Dialog content area, the focus moves away from the Dialog component. As a result, the Dialog does not receive keyboard events, and pressing the `ESC` key does not close it. This behavior occurs because the keydown events are not invoked for the Dialog when the focus is on another element or the body tag.
@@ -28,8 +29,13 @@ To ensure the Dialog closes on `ESC` even after focusing the content, wrap the D
28
29
Width="500px"
29
30
Height="300px"
30
31
Class="focusable-content">
32
+
<DialogTitle>
33
+
<div tabindex="0" class="dialog-wrapper">
34
+
Focusable Title
35
+
</div>
36
+
</DialogTitle>
31
37
<DialogContent>
32
-
<div tabindex="0" class="dialog-content-wrapper">
38
+
<div tabindex="0" class="dialog-wrapper">
33
39
<p>Click anywhere in this content area, then press ESC to close the dialog.</p>
34
40
</div>
35
41
</DialogContent>
@@ -46,8 +52,19 @@ To ensure the Dialog closes on `ESC` even after focusing the content, wrap the D
46
52
padding: 0;
47
53
}
48
54
55
+
/* Remove default Dialog title padding to let wrapper handle it */
56
+
.focusable-content .k-dialog-titlebar {
57
+
padding: 0;
58
+
}
59
+
60
+
/* Focusable wrapper that fills the entire Dialog title area */
61
+
.focusable-content .k-dialog-titlebar-actions {
62
+
padding-block: var(--kendo-spacing-3, 0.75rem);
63
+
padding-inline: var(--kendo-spacing-4, 1rem);
64
+
}
65
+
49
66
/* Focusable wrapper that fills the entire Dialog content area */
50
-
.focusable-content .dialog-content-wrapper {
67
+
.focusable-content .dialog-wrapper {
51
68
padding: 1rem;
52
69
outline: none;
53
70
height: 100%;
@@ -56,9 +73,9 @@ To ensure the Dialog closes on `ESC` even after focusing the content, wrap the D
56
73
}
57
74
58
75
/* Optional visual indication when the wrapper is focused */
0 commit comments