Skip to content

Commit ba99a45

Browse files
ErikMikkelsonMajesticPotatoe
authored andcommitted
fix(vdialog): fix close on outside click with persist and hide-overlay (#9304)
* fix(vdialog): fix close on outside click with persist and hide-overlay Fixes an issue where VDialog would close on outside clicks if persist and hide-overlay were set. fix #8697 * fix(vdialog): persistent and hide-overlay should ignore outside click ixes an issue where the dialog would still close on outside clicks when persistent and hide-overlay fix #8697
1 parent 283d601 commit ba99a45

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

packages/vuetify/src/components/VDialog/VDialog.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,8 @@ export default baseMixins.extend({
173173
// click is on the overlay, animate
174174
this.$emit('click:outside')
175175

176-
if (this.persistent && this.overlay) {
177-
if (
178-
!this.noClickAnimation &&
179-
(
180-
this.overlay.$el === target ||
181-
this.overlay.$el.contains(target)
182-
)
183-
) this.animateClick()
176+
if (this.persistent) {
177+
!this.noClickAnimation && this.animateClick()
184178

185179
return false
186180
}

packages/vuetify/src/components/VDialog/__tests__/VDialog.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,36 @@ describe('VDialog.ts', () => {
312312
expect(content.element.tabIndex).toBe(0)
313313
expect(content.html()).toMatchSnapshot()
314314
})
315+
316+
// https://github.com/vuetifyjs/vuetify/issues/8697
317+
it('should not close if persistent and hide-overly when click outside', async () => {
318+
const input = jest.fn()
319+
const clickOutside = jest.fn()
320+
const wrapper = mountFunction({
321+
propsData: {
322+
persistent: true,
323+
hideOverlay: true,
324+
},
325+
scopedSlots: {
326+
activator ({ on }) {
327+
return this.$createElement('div', {
328+
staticClass: 'activator',
329+
on,
330+
})
331+
},
332+
},
333+
})
334+
335+
wrapper.vm.$on('input', input)
336+
wrapper.vm.$on('click:outside', clickOutside)
337+
338+
expect(wrapper.vm.isActive).toBe(false)
339+
wrapper.find('div.activator').trigger('click')
340+
expect(wrapper.vm.isActive).toBe(true)
341+
await wrapper.vm.$nextTick()
342+
expect(input).toHaveBeenCalledWith(true)
343+
wrapper.vm.closeConditional(new Event('click'))
344+
expect(clickOutside).toHaveBeenCalled()
345+
expect(wrapper.vm.isActive).toBe(true)
346+
})
315347
})

0 commit comments

Comments
 (0)