Skip to content

Commit

Permalink
fix: correct popover opening with new slot syntax and no title/content
Browse files Browse the repository at this point in the history
  • Loading branch information
damirbogdanov committed Sep 8, 2023
1 parent f6f0dff commit 04887dd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
},
methods: {
isNotEmpty() {
return this.title || this.content || this.$slots.popover
return this.title || this.content || this.$scopedSlots.popover
},
},
}
27 changes: 27 additions & 0 deletions src/components/popover/Popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,31 @@ This is a very very long text. This is a very very long text. This is a very ver
await sleep(600)
expect(document.querySelectorAll('.popover').length).toEqual(1)
})

it('should be able to open popover programmatically with vue latest slot syntax and without title and content passed', async () => {
const wrapper = createWrapper(
`
<div>
<popover v-model="show">
<btn type="primary" id="btn">Popover</btn>
<template #popover>
<h1>Hello world!</h1>
</template>
</popover>
</div>
`,
{
show: false,
}
)
const vm = wrapper.vm
await vm.$nextTick()
expect(document.querySelectorAll('.popover').length).toEqual(0)
vm.show = true
await sleep(300)
expect(document.querySelectorAll('.popover').length).toEqual(1)
vm.show = false
await sleep(300)
expect(document.querySelectorAll('.popover').length).toEqual(0)
})
})

0 comments on commit 04887dd

Please sign in to comment.