Skip to content

Commit

Permalink
Ensure focus is moved to modal after animation completes (Fixes #829)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Nov 18, 2022
1 parent 887ca08 commit b91cfbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* **css:** Updated stylelint ruleset to match Bedrock's linting pattern. (#814)

## Bug Fixes
* **js:** Ensure focus is moved to modal after animation completes (#829)
* **node:** Make sure to build NPM package using production mode.
* **html:** Added accessible attributes to menu bar (#815).
* **css:** Add style rule for the hidden attribute in global reset (#783).
Expand Down
12 changes: 6 additions & 6 deletions assets/js/protocol/protocol-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ if (typeof window.Mzp === 'undefined') { // eslint-disable-line block-scoped-var

content.classList.add('mzp-c-modal-overlay-contents');

// ensure focus is moved to the modal only after CSS animation completes.
// issue: https://github.com/mozilla/protocol/issues/829
modal.addEventListener('animationend', function () {
modal.focus();
}, false);

// close modal on clicking close button or background.
var closeButton = document.querySelector('.mzp-c-modal-button-close');
closeButton.addEventListener('click', Modal.closeModal, false);
Expand All @@ -88,12 +94,6 @@ if (typeof window.Mzp === 'undefined') { // eslint-disable-line block-scoped-var
}
}, false);

// add a short delay is need before calling focus() to give
// time for the fade-in animation to complete (issue #749).
setTimeout(function() {
modal.focus();
}, 300);

// close with escape key
document.addEventListener('keyup', _onDocumentKeyUp, false);

Expand Down

0 comments on commit b91cfbb

Please sign in to comment.