Skip to content

Commit 05ef925

Browse files
committed
fix(VOverlay): don't emit keydown.esc if not the top overlay
1 parent 0ca7e93 commit 05ef925

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/vuetify/src/components/VOverlay/VOverlay.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export const VOverlay = genericComponent<OverlaySlots>()({
129129
emits: {
130130
'click:outside': (e: MouseEvent) => true,
131131
'update:modelValue': (value: boolean) => true,
132+
keydown: (e: KeyboardEvent) => true,
132133
afterEnter: () => true,
133134
afterLeave: () => true,
134135
},
@@ -218,6 +219,9 @@ export const VOverlay = genericComponent<OverlaySlots>()({
218219

219220
function onKeydown (e: KeyboardEvent) {
220221
if (e.key === 'Escape' && globalTop.value) {
222+
if (!contentEl.value?.contains(document.activeElement)) {
223+
emit('keydown', e)
224+
}
221225
if (!props.persistent) {
222226
isActive.value = false
223227
if (contentEl.value?.contains(document.activeElement)) {
@@ -226,6 +230,11 @@ export const VOverlay = genericComponent<OverlaySlots>()({
226230
} else animateClick()
227231
}
228232
}
233+
function onKeydownSelf (e: KeyboardEvent) {
234+
if (e.key === 'Escape' && !globalTop.value) return
235+
236+
emit('keydown', e)
237+
}
229238

230239
const router = useRouter()
231240
useToggleScope(() => props.closeOnBack, () => {
@@ -309,6 +318,7 @@ export const VOverlay = genericComponent<OverlaySlots>()({
309318
props.style,
310319
]}
311320
ref={ root }
321+
onKeydown={ onKeydownSelf }
312322
{ ...scopeId }
313323
{ ...attrs }
314324
>

0 commit comments

Comments
 (0)