Skip to content

Commit f2303f1

Browse files
kuromokaMajesticPotatoe
authored andcommitted
fix(VDialog): remove console error on escape keypress (#7030)
* fix(VDialog): pass event parameter * test(VDialog): add test on escape keydown * fix(VDialog): remove consoleError
1 parent 415f8ca commit f2303f1

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

β€Žpackages/vuetify/src/components/VDialog/VDialog.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export default {
234234
if (el) return el
235235
}
236236

237-
consoleError('No activator found')
237+
return null
238238
},
239239
genActivator () {
240240
if (!this.hasActivator) return null

β€Žpackages/vuetify/test/unit/components/VDialog/VDialog.spec.jsβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import VDialog from '@/components/VDialog'
22
import { test } from '@/test'
3+
import { keyCodes } from '@/util/helpers'
34
import Vue from 'vue'
45

56
test('VDialog.js', ({ mount, compileToFunctions }) => {
@@ -252,4 +253,17 @@ test('VDialog.js', ({ mount, compileToFunctions }) => {
252253

253254
expect('Unable to locate target [data-app]').toHaveBeenTipped()
254255
})
256+
257+
it('should close dialog on escape keydown', () => {
258+
const wrapper = mount(VDialog, {
259+
propsData: { value: true }
260+
})
261+
262+
const escape = new Event('keydown')
263+
escape.keyCode = keyCodes.esc
264+
wrapper.vm.$refs.content.dispatchEvent(escape)
265+
expect(wrapper.vm.isActive).toBe(false)
266+
267+
expect('Unable to locate target [data-app]').toHaveBeenTipped()
268+
})
255269
})

0 commit comments

Comments
Β (0)