Skip to content

Commit

Permalink
fix(tooltip): get tip on placement change
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Jun 25, 2018
1 parent 4112df4 commit e57a2f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,11 @@ const Tooltip = (($) => {
}
}

_handlePopperPlacementChange(data) {
_handlePopperPlacementChange(popperData) {
const popperInstance = popperData.instance
this.tip = popperInstance.popper
this._cleanTipClass()
this.addAttachmentClass(this._getAttachment(data.placement))
this.addAttachmentClass(this._getAttachment(popperData.placement))
}

_fixTransition() {
Expand Down
23 changes: 23 additions & 0 deletions js/tests/unit/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,27 @@ $(function () {

assert.ok(tooltip._popper === null)
})

QUnit.test('should use Popper.js to get the tip on placement change', function (assert) {
assert.expect(1)

var $tooltip = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip()

var $tipTest = $('<div class="bs-tooltip" />')
.appendTo('#qunit-fixture')

var tooltip = $tooltip.data('bs.tooltip')
tooltip.tip = null

tooltip._handlePopperPlacementChange({
instance: {
popper: $tipTest[0]
},
placement: 'auto'
})

assert.ok(tooltip.tip === $tipTest[0])
})
})

0 comments on commit e57a2f2

Please sign in to comment.