0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-19 11:52:21 +01:00

prevent tooltip from being deleted on quick re-activations

This commit is contained in:
Ryan Berliner 2021-03-06 03:35:28 +02:00 committed by XhmikosR
parent 6ecd1c626e
commit d491c29aa0
2 changed files with 33 additions and 0 deletions

View File

@ -329,6 +329,10 @@ class Tooltip extends BaseComponent {
const tip = this.getTipElement() const tip = this.getTipElement()
const complete = () => { const complete = () => {
if (this._isWithActiveTrigger()) {
return
}
if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) { if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip) tip.parentNode.removeChild(tip)
} }

View File

@ -708,6 +708,35 @@ describe('Tooltip', () => {
tooltipEl.dispatchEvent(createEvent('mouseover')) tooltipEl.dispatchEvent(createEvent('mouseover'))
}) })
it('should not hide tooltip if leave event occurs and enter event occurs during hide transition', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl)
spyOn(window, 'getComputedStyle').and.returnValue({
transitionDuration: '0.15s',
transitionDelay: '0s'
})
setTimeout(() => {
expect(tooltip._popper).not.toBeNull()
tooltipEl.dispatchEvent(createEvent('mouseout'))
setTimeout(() => {
expect(tooltip.getTipElement().classList.contains('show')).toEqual(false)
tooltipEl.dispatchEvent(createEvent('mouseover'))
}, 100)
setTimeout(() => {
expect(tooltip._popper).not.toBeNull()
done()
}, 200)
}, 0)
tooltipEl.dispatchEvent(createEvent('mouseover'))
})
it('should show a tooltip with custom class provided in data attributes', done => { it('should show a tooltip with custom class provided in data attributes', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip" data-bs-custom-class="custom-class">' fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip" data-bs-custom-class="custom-class">'