Skip to content

Commit

Permalink
Fix: Popup support in a11y disabled (fixes #616)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Jan 16, 2025
1 parent 5d58a50 commit abcca6d
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit abcca6d

Please sign in to comment.