Skip to content

Commit

Permalink
fix(vdialog): fix close on outside click with persist and hide-overlay (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
ErikMikkelson authored and MajesticPotatoe committed Oct 24, 2019
1 parent 283d601 commit ba99a45
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/vuetify/src/components/VDialog/VDialog.ts
Expand Up @@ -173,14 +173,8 @@ export default baseMixins.extend({
// click is on the overlay, animate
this.$emit('click:outside')

if (this.persistent && this.overlay) {
if (
!this.noClickAnimation &&
(
this.overlay.$el === target ||
this.overlay.$el.contains(target)
)
) this.animateClick()
if (this.persistent) {
!this.noClickAnimation && this.animateClick()

return false
}
Expand Down
32 changes: 32 additions & 0 deletions packages/vuetify/src/components/VDialog/__tests__/VDialog.spec.ts
Expand Up @@ -312,4 +312,36 @@ describe('VDialog.ts', () => {
expect(content.element.tabIndex).toBe(0)
expect(content.html()).toMatchSnapshot()
})

// https://github.com/vuetifyjs/vuetify/issues/8697
it('should not close if persistent and hide-overly when click outside', async () => {
const input = jest.fn()
const clickOutside = jest.fn()
const wrapper = mountFunction({
propsData: {
persistent: true,
hideOverlay: true,
},
scopedSlots: {
activator ({ on }) {
return this.$createElement('div', {
staticClass: 'activator',
on,
})
},
},
})

wrapper.vm.$on('input', input)
wrapper.vm.$on('click:outside', clickOutside)

expect(wrapper.vm.isActive).toBe(false)
wrapper.find('div.activator').trigger('click')
expect(wrapper.vm.isActive).toBe(true)
await wrapper.vm.$nextTick()
expect(input).toHaveBeenCalledWith(true)
wrapper.vm.closeConditional(new Event('click'))
expect(clickOutside).toHaveBeenCalled()
expect(wrapper.vm.isActive).toBe(true)
})
})

0 comments on commit ba99a45

Please sign in to comment.