Skip to content

Commit 9740d8b

Browse files
Phil Hugheshnrch02
Phil Hughes
authored andcommitted
Fix tooltip occasionally not hiding when using a hide delay
Fixes twbs#14375. Closes twbs#14519 by merging it.
1 parent 783eced commit 9740d8b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

js/tests/unit/tooltip.js

+30
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,36 @@ $(function () {
928928
$tooltip.trigger('mouseenter')
929929
})
930930

931+
test('should hide tip after hide delay even if moused left before end of fade in', function () {
932+
stop()
933+
934+
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip for test"/>')
935+
.appendTo('#qunit-fixture')
936+
.bootstrapTooltip({ delay: { show: 10, hide: 10 }})
937+
938+
setTimeout(function () {
939+
ok(!$tooltip.data('bs.tooltip').$tip, '1ms: tooltip exists')
940+
941+
setTimeout(function () {
942+
ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '10ms: tooltip faded in')
943+
}, 10)
944+
945+
setTimeout(function () {
946+
ok($tooltip.data('bs.tooltip').$tip.is('.fade.in'), '15ms: tooltip faded in')
947+
948+
$tooltip.trigger('mouseout')
949+
}, 15)
950+
951+
setTimeout(function () {
952+
ok(!$tooltip.data('bs.tooltip').$tip.is('.fade.in'), '30ms: tooltip faded out')
953+
954+
start()
955+
}, 30)
956+
}, 0)
957+
958+
$tooltip.trigger('mouseenter')
959+
})
960+
931961
test('should correctly position tooltips on SVG elements', function () {
932962
if (!window.SVGElement) {
933963
// Skip IE8 since it doesn't support SVG

js/tooltip.js

+3
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@
207207
this.applyPlacement(calculatedOffset, placement)
208208

209209
var complete = function () {
210+
var prevHoverState = that.hoverState
210211
that.$element.trigger('shown.bs.' + that.type)
211212
that.hoverState = null
213+
214+
if (prevHoverState == 'out') that.leave(that)
212215
}
213216

214217
$.support.transition && this.$tip.hasClass('fade') ?

0 commit comments

Comments
 (0)