diff --git a/packages/vuetify/src/components/VDialog/VDialog.js b/packages/vuetify/src/components/VDialog/VDialog.js index 3086720c85e..bd4abda0ab3 100644 --- a/packages/vuetify/src/components/VDialog/VDialog.js +++ b/packages/vuetify/src/components/VDialog/VDialog.js @@ -84,6 +84,12 @@ export default { 'v-dialog__content': true, 'v-dialog__content--active': this.isActive } + }, + hasActivator () { + return Boolean( + !!this.$slots.activator || + !!this.$scopedSlots.activator + ) } }, @@ -177,7 +183,7 @@ export default { this.$emit('keydown', e) }, genActivator () { - if (!this.$slots.activator && !this.$scopedSlots.activator) return null + if (!this.hasActivator) return null const listeners = this.disabled ? {} : { click: e => { @@ -263,7 +269,7 @@ export default { return h('div', { staticClass: 'v-dialog__container', style: { - display: (!this.$slots.activator || this.fullWidth) ? 'block' : 'inline-block' + display: (!this.hasActivator || this.fullWidth) ? 'block' : 'inline-block' } }, children) } diff --git a/packages/vuetify/test/unit/components/VDialog/VDialog.spec.js b/packages/vuetify/test/unit/components/VDialog/VDialog.spec.js index 9aa95b7ec59..5cc2a7303c5 100644 --- a/packages/vuetify/test/unit/components/VDialog/VDialog.spec.js +++ b/packages/vuetify/test/unit/components/VDialog/VDialog.spec.js @@ -1,5 +1,6 @@ import VDialog from '@/components/VDialog' import { test } from '@/test' +import Vue from 'vue' test('VDialog.js', ({ mount, compileToFunctions }) => { it('should render component and match snapshot', () => { @@ -230,4 +231,32 @@ test('VDialog.js', ({ mount, compileToFunctions }) => { expect('Unable to locate target [data-app]').toHaveBeenTipped() }) + + // https://github.com/vuetifyjs/vuetify/issues/6115 + it('should have activator', () => { + const wrapper = mount(VDialog) + expect(wrapper.vm.hasActivator).toBe(false) + expect(wrapper.hasStyle('display', 'block')).toBe(true) + + const wrapper2 = mount(VDialog, { + slots: { + activator: [compileToFunctions('
')] + } + }) + expect(wrapper2.hasStyle('display', 'inline-block')).toBe(true) + expect(wrapper2.vm.hasActivator).toBe(true) + + const wrapper3 = mount({ + render: h => h(VDialog, { + scopedSlots: { + activator: () => '
' + } + }) + }) + const dialog = wrapper3.first(VDialog) + expect(dialog.hasStyle('display', 'inline-block')).toBe(true) + expect(dialog.vm.hasActivator).toBe(true) + + expect('Unable to locate target [data-app]').toHaveBeenTipped() + }) })