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

Fix: Popup support in a11y disabled (fixes #616) #617

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions js/a11y/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ export default class Popup extends Backbone.Controller {
*/
_addPopupLayer($popupElement) {
$popupElement = $($popupElement);
const config = this.a11y.config;
if (!config._isEnabled || !config._options._isPopupManagementEnabled || $popupElement.length === 0) {
return $popupElement;
}
this._floorStack.push($popupElement);
this._focusStack.push($(document.activeElement));
if ($popupElement.is('dialog')) {
$popupElement[0].addEventListener('cancel', event => event.preventDefault());
$popupElement[0].showModal();
return;
}
const config = this.a11y.config;
if (!config._isEnabled || !config._options._isPopupManagementEnabled || $popupElement.length === 0) {
return $popupElement;
}
logging.deprecated('a11y/popup opened: Use native dialog tag for', $popupElement);
let $elements = $(config._options._tabbableElements).filter(config._options._tabbableElementsExcludes);
const $branch = $popupElement.add($popupElement.parents());
Expand Down Expand Up @@ -166,10 +166,6 @@ export default class Popup extends Backbone.Controller {
* @returns {Object} Returns previously active element.
*/
_removeLastPopupLayer() {
const config = this.a11y.config;
if (!config._isEnabled || !config._options._isPopupManagementEnabled) {
return $(document.activeElement);
}
// the body layer is the first element and must always exist
if (this._floorStack.length <= 1) {
return;
Expand All @@ -179,6 +175,10 @@ export default class Popup extends Backbone.Controller {
$popupElement[0].close();
return this._focusStack.pop();
}
const config = this.a11y.config;
if (!config._isEnabled || !config._options._isPopupManagementEnabled) {
return $(document.activeElement);
}
$(config._options._tabbableElements).filter(config._options._tabbableElementsExcludes).each((index, item) => {
const $item = $(item);
let previousTabIndex = '';
Expand Down
Loading