1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-20 04:11:39 +02:00

Handle aria-hidden on modal container when showing/hiding

Fixes #19878
This commit is contained in:
Patrick H. Lauke
2016-05-10 23:53:49 +01:00
parent 5aa32b3f3a
commit b107e3342a
2 changed files with 19 additions and 0 deletions

View File

@@ -223,6 +223,7 @@ const Modal = (($) => {
} }
this._element.style.display = 'block' this._element.style.display = 'block'
this._element.removeAttribute('aria-hidden')
this._element.scrollTop = 0 this._element.scrollTop = 0
if (transition) { if (transition) {
@@ -290,6 +291,7 @@ const Modal = (($) => {
_hideModal() { _hideModal() {
this._element.style.display = 'none' this._element.style.display = 'none'
this._element.setAttribute('aria-hidden', 'true')
this._showBackdrop(() => { this._showBackdrop(() => {
$(document.body).removeClass(ClassName.OPEN) $(document.body).removeClass(ClassName.OPEN)
this._resetAdjustments() this._resetAdjustments()

View File

@@ -233,6 +233,23 @@ $(function () {
.bootstrapModal('show') .bootstrapModal('show')
}) })
QUnit.test('should remove aria-hidden attribute when shown, add it back when hidden', function (assert) {
assert.expect(3)
var done = assert.async()
$('<div id="modal-test" aria-hidden="true"/>')
.on('shown.bs.modal', function () {
assert.notOk($('#modal-test').is('[aria-hidden]'), 'aria-hidden attribute removed')
$(this).bootstrapModal('hide')
})
.on('hidden.bs.modal', function () {
assert.ok($('#modal-test').is('[aria-hidden]'), 'aria-hidden attribute added')
assert.strictEqual($('#modal-test').attr('aria-hidden'), 'true', 'correct aria-hidden="true" added')
done()
})
.bootstrapModal('show')
})
QUnit.test('should close reopened modal with [data-dismiss="modal"] click', function (assert) { QUnit.test('should close reopened modal with [data-dismiss="modal"] click', function (assert) {
assert.expect(2) assert.expect(2)
var done = assert.async() var done = assert.async()