mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-74701 core: Fix popover elements are focusable even when hidden
This commit is contained in:
parent
ca583bddaf
commit
47c6c30178
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -129,6 +129,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
|
||||
this.menuContainer.attr('aria-expanded', 'false');
|
||||
this.menuContainer.attr('aria-hidden', 'true');
|
||||
this.updateButtonAriaLabel();
|
||||
this.updateFocusItemTabIndex();
|
||||
this.root.trigger(this.events().menuClosed);
|
||||
};
|
||||
|
||||
@ -149,6 +150,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
|
||||
this.menuContainer.attr('aria-expanded', 'true');
|
||||
this.menuContainer.attr('aria-hidden', 'false');
|
||||
this.updateButtonAriaLabel();
|
||||
this.updateFocusItemTabIndex();
|
||||
// Resolve the promises to allow the handlers to be added
|
||||
// to the DOM, if they have been requested.
|
||||
this.promises.closeHandlers.resolve();
|
||||
@ -392,5 +394,18 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the appropriate tabindex attribute on the popover toggle.
|
||||
*
|
||||
* @method updateFocusItemTabIndex
|
||||
*/
|
||||
PopoverRegionController.prototype.updateFocusItemTabIndex = function() {
|
||||
if (this.isMenuOpen()) {
|
||||
this.menuContainer.find(SELECTORS.CAN_RECEIVE_FOCUS).removeAttr('tabindex');
|
||||
} else {
|
||||
this.menuContainer.find(SELECTORS.CAN_RECEIVE_FOCUS).attr('tabindex', '-1');
|
||||
}
|
||||
};
|
||||
|
||||
return PopoverRegionController;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user