Skip to content

Commit

Permalink
update click state when hiding so can be shown again by trigger. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbeatty authored and mdo committed Dec 27, 2016
1 parent 8a3d0d3 commit aa7f95f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ const Tooltip = (($) => {

$(tip).removeClass(ClassName.SHOW)

this._activeTrigger[Trigger.CLICK] = false
this._activeTrigger[Trigger.FOCUS] = false
this._activeTrigger[Trigger.HOVER] = false

if (Util.supportsTransitionEnd() &&
$(this.tip).hasClass(ClassName.FADE)) {
this._isTransitioning = true
Expand Down
21 changes: 21 additions & 0 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,4 +818,25 @@ $(function () {
})
})

QUnit.test('should show on first trigger after hide', function (assert) {
assert.expect(3)
var $el = $('<a href="#" rel="tooltip" title="Test tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ trigger: 'click hover focus', animation: false })

var tooltip = $el.data('bs.tooltip')
var $tooltip = $(tooltip.getTipElement())

function showingTooltip() { return $tooltip.hasClass('show') || tooltip._hoverState === 'show' }

$el.trigger('click')
assert.ok(showingTooltip(), 'tooltip is faded in')

$el.bootstrapTooltip('hide')
assert.ok(!showingTooltip(), 'tooltip was faded out')

$el.trigger('click')
assert.ok(showingTooltip(), 'tooltip is faded in again')
})

})

0 comments on commit aa7f95f

Please sign in to comment.