mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-74073 courseformat: Toggle Collapse/Expand all via space key
* Add 'space' keydown event handler on the Collapse/Expand all element on the course homepage. * Set aria-expanded attribute of the Expand/Collapse all element accordingly Reference: https://www.w3.org/TR/wai-aria-practices-1.1/#disclosure
This commit is contained in:
parent
ed55f45754
commit
b9ff0ff99b
2
course/format/amd/build/local/content.min.js
vendored
2
course/format/amd/build/local/content.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -106,6 +106,12 @@ export default class Component extends BaseComponent {
|
||||
const toogleAll = this.getElement(this.selectors.TOGGLEALL);
|
||||
if (toogleAll) {
|
||||
this.addEventListener(toogleAll, 'click', this._allSectionToggler);
|
||||
this.addEventListener(toogleAll, 'keydown', e => {
|
||||
// Collapse/expand all sections when Space key is pressed on the toggle button.
|
||||
if (e.key === ' ') {
|
||||
this._allSectionToggler(e);
|
||||
}
|
||||
});
|
||||
this._refreshAllSectionsToggler(state);
|
||||
}
|
||||
|
||||
@ -263,9 +269,11 @@ export default class Component extends BaseComponent {
|
||||
);
|
||||
if (allcollapsed) {
|
||||
target.classList.add(this.classes.COLLAPSED);
|
||||
target.setAttribute('aria-expanded', false);
|
||||
}
|
||||
if (allexpanded) {
|
||||
target.classList.remove(this.classes.COLLAPSED);
|
||||
target.setAttribute('aria-expanded', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user