mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
116404: Apply focus on first item
(cherry picked from commit 2152bab717
)
This commit is contained in:
@@ -83,10 +83,13 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
|||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
if (this.addArrowEventListeners) {
|
if (this.addArrowEventListeners) {
|
||||||
const dropdownItems = document.querySelectorAll(`#${this.expandableNavbarSectionId()} *[role="menuitem"]`);
|
const dropdownItems: NodeListOf<HTMLElement> = document.querySelectorAll(`#${this.expandableNavbarSectionId()} *[role="menuitem"]`);
|
||||||
dropdownItems.forEach(item => {
|
dropdownItems.forEach((item: HTMLElement) => {
|
||||||
item.addEventListener('keydown', this.navigateDropdown.bind(this));
|
item.addEventListener('keydown', this.navigateDropdown.bind(this));
|
||||||
});
|
});
|
||||||
|
if (dropdownItems.length > 0) {
|
||||||
|
dropdownItems.item(0).focus();
|
||||||
|
}
|
||||||
this.addArrowEventListeners = false;
|
this.addArrowEventListeners = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +169,7 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
|||||||
this.deactivateSection(event, false);
|
this.deactivateSection(event, false);
|
||||||
break;
|
break;
|
||||||
case 'ArrowDown':
|
case 'ArrowDown':
|
||||||
this.navigateDropdown(event);
|
this.activateSection(event);
|
||||||
break;
|
break;
|
||||||
case 'Space':
|
case 'Space':
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@@ -75,9 +75,12 @@ export class MenuSectionComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Activate this section
|
* Activate this section
|
||||||
* @param {Event} event The user event that triggered this method
|
* @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) {
|
activateSection(event: Event, skipEvent = true): void {
|
||||||
event.preventDefault();
|
if (skipEvent) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
if (!this.section.model?.disabled) {
|
if (!this.section.model?.disabled) {
|
||||||
this.menuService.activateSection(this.menuID, this.section.id);
|
this.menuService.activateSection(this.menuID, this.section.id);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user