Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle aria-hidden on modal container when showing/hiding #19879

Merged
merged 1 commit into from
May 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const Modal = (($) => {
}

this._element.style.display = 'block'
this._element.removeAttribute('aria-hidden')
this._element.scrollTop = 0

if (transition) {
Expand Down Expand Up @@ -290,6 +291,7 @@ const Modal = (($) => {

_hideModal() {
this._element.style.display = 'none'
this._element.setAttribute('aria-hidden', 'true')
this._showBackdrop(() => {
$(document.body).removeClass(ClassName.OPEN)
this._resetAdjustments()
Expand Down
17 changes: 17 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,23 @@ $(function () {
.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) {
assert.expect(2)
var done = assert.async()
Expand Down