Skip to content

Commit

Permalink
Fix popover remaining open when toggled after being shown (#40803)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Sergienko <dmitry.sergienko@codefirst.net>
Co-authored-by: Julien Déramond <juderamond@gmail.com>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent dcec1df commit fecd219
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class Tooltip extends BaseComponent {
return
}

this._activeTrigger.click = !this._activeTrigger.click
if (this._isShown()) {
this._leave()
return
Expand Down
20 changes: 20 additions & 0 deletions js/tests/unit/popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ describe('Popover', () => {
})

describe('show', () => {
it('should toggle a popover after show', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="https://twitter.com/getbootstrap">BS twitter</a>'

const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl)

popoverEl.addEventListener('shown.bs.popover', () => {
expect(document.querySelector('.popover')).not.toBeNull()
popover.toggle()
})
popoverEl.addEventListener('hidden.bs.popover', () => {
expect(document.querySelector('.popover')).toBeNull()
resolve()
})

popover.show()
})
})

it('should show a popover', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="https://twitter.com/getbootstrap">BS twitter</a>'
Expand Down

0 comments on commit fecd219

Please sign in to comment.