mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
handle detached tooltip when we try to hide a modal
This commit is contained in:
parent
e0d1f3f18b
commit
f7a4b39767
@ -486,13 +486,17 @@ class Tooltip {
|
||||
(event) => this._leave(event)
|
||||
)
|
||||
}
|
||||
|
||||
$(this.element).closest('.modal').on(
|
||||
'hide.bs.modal',
|
||||
() => this.hide()
|
||||
)
|
||||
})
|
||||
|
||||
$(this.element).closest('.modal').on(
|
||||
'hide.bs.modal',
|
||||
() => {
|
||||
if (this.element) {
|
||||
this.hide()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (this.config.selector) {
|
||||
this.config = {
|
||||
...this.config,
|
||||
|
@ -862,6 +862,44 @@ $(function () {
|
||||
.modal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should allow to close modal if the tooltip element is detached', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
var templateHTML = [
|
||||
'<div id="modal-test" class="modal">',
|
||||
' <div class="modal-dialog" role="document">',
|
||||
' <div class="modal-content">',
|
||||
' <div class="modal-body">',
|
||||
' <a id="tooltipTest" href="#" data-toggle="tooltip" title="Some tooltip text!">Tooltip</a>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
$(templateHTML).appendTo('#qunit-fixture')
|
||||
var $tooltip = $('#tooltipTest')
|
||||
var $modal = $('#modal-test')
|
||||
|
||||
$tooltip.on('shown.bs.tooltip', function () {
|
||||
$tooltip.detach()
|
||||
$tooltip.bootstrapTooltip('dispose')
|
||||
$modal.modal('hide')
|
||||
})
|
||||
|
||||
$modal.on('shown.bs.modal', function () {
|
||||
$tooltip.bootstrapTooltip({
|
||||
trigger: 'manuel'
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
assert.ok(true, 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.modal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should reset tip classes when hidden event triggered', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
@ -966,4 +1004,24 @@ $(function () {
|
||||
|
||||
assert.ok(tooltip.tip === $tipTest[0])
|
||||
})
|
||||
|
||||
QUnit.test('should toggle enabled', function (assert) {
|
||||
assert.expect(3)
|
||||
|
||||
var $tooltip = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip()
|
||||
|
||||
var tooltip = $tooltip.data('bs.tooltip')
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, true)
|
||||
|
||||
tooltip.toggleEnabled()
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, false)
|
||||
|
||||
tooltip.toggleEnabled()
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, true)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user