Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tooltip hide method when already hidden #31115

Merged
merged 7 commits into from Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions js/src/tooltip.js
Expand Up @@ -331,6 +331,10 @@ class Tooltip {
}

hide() {
if (!this._popper) {
return
}

const tip = this.getTipElement()
const complete = () => {
if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
Expand Down
14 changes: 14 additions & 0 deletions js/tests/unit/tooltip.spec.js
Expand Up @@ -717,6 +717,20 @@ describe('Tooltip', () => {

tooltip.show()
})

it('should not throw error running hide if popper hasn\'t been shown', () => {
fixtureEl.innerHTML = '<div></div>'

const div = fixtureEl.querySelector('div')
const tooltip = new Tooltip(div)

try {
tooltip.hide()
Johann-S marked this conversation as resolved.
Show resolved Hide resolved
expect().nothing()
} catch {
throw new Error('should not throw error')
}
})
})

describe('update', () => {
Expand Down