Skip to content

Commit

Permalink
fix(VDialog): properly check for activator scopedSlot
Browse files Browse the repository at this point in the history
fixes #6115
  • Loading branch information
johnleider committed Jan 18, 2019
1 parent adfd142 commit 2acf2ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/vuetify/src/components/VDialog/VDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
},

Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
}
Expand Down
29 changes: 29 additions & 0 deletions packages/vuetify/test/unit/components/VDialog/VDialog.spec.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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('<div></div>')]
}
})
expect(wrapper2.hasStyle('display', 'inline-block')).toBe(true)
expect(wrapper2.vm.hasActivator).toBe(true)

const wrapper3 = mount({
render: h => h(VDialog, {
scopedSlots: {
activator: () => '<div></div>'
}
})
})
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()
})
})

0 comments on commit 2acf2ff

Please sign in to comment.