mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
116404: Apply focus on first item
(cherry picked from commit 2152bab717
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
b9b1d3fd8d
commit
eb93041c5b
@@ -112,10 +112,13 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
if (this.addArrowEventListeners) {
|
||||
const dropdownItems = document.querySelectorAll(`#${this.expandableNavbarSectionId()} *[role="menuitem"]`);
|
||||
dropdownItems.forEach(item => {
|
||||
const dropdownItems: NodeListOf<HTMLElement> = document.querySelectorAll(`#${this.expandableNavbarSectionId()} *[role="menuitem"]`);
|
||||
dropdownItems.forEach((item: HTMLElement) => {
|
||||
item.addEventListener('keydown', this.navigateDropdown.bind(this));
|
||||
});
|
||||
if (dropdownItems.length > 0) {
|
||||
dropdownItems.item(0).focus();
|
||||
}
|
||||
this.addArrowEventListeners = false;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +198,7 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
||||
this.deactivateSection(event, false);
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
this.navigateDropdown(event);
|
||||
this.activateSection(event);
|
||||
break;
|
||||
case 'Space':
|
||||
event.preventDefault();
|
||||
|
@@ -92,9 +92,12 @@ export class MenuSectionComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* Activate this section
|
||||
* @param {Event} event The user event that triggered this method
|
||||
* @param skipEvent Weather the event should still be triggered after deactivating the section or not
|
||||
*/
|
||||
activateSection(event: Event) {
|
||||
event.preventDefault();
|
||||
activateSection(event: Event, skipEvent = true): void {
|
||||
if (skipEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (!this.section.model?.disabled) {
|
||||
this.menuService.activateSection(this.menuID, this.section.id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user