mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
116404: Fixed expandable navbar section loosing focus on expand through keyboard
(cherry picked from commit 2547b1218f
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
bb977dcd49
commit
ed27231769
@@ -84,7 +84,7 @@ export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionC
|
|||||||
this.sidebarActiveBg$ = this.variableService.getVariable('--ds-admin-sidebar-active-bg');
|
this.sidebarActiveBg$ = this.variableService.getVariable('--ds-admin-sidebar-active-bg');
|
||||||
this.isSidebarCollapsed$ = this.menuService.isMenuCollapsed(this.menuID);
|
this.isSidebarCollapsed$ = this.menuService.isMenuCollapsed(this.menuID);
|
||||||
this.isSidebarPreviewCollapsed$ = this.menuService.isMenuPreviewCollapsed(this.menuID);
|
this.isSidebarPreviewCollapsed$ = this.menuService.isMenuPreviewCollapsed(this.menuID);
|
||||||
this.isExpanded$ = combineLatestObservable([this.active, this.isSidebarCollapsed$, this.isSidebarPreviewCollapsed$]).pipe(
|
this.isExpanded$ = combineLatestObservable([this.active$, this.isSidebarCollapsed$, this.isSidebarPreviewCollapsed$]).pipe(
|
||||||
map(([active, sidebarCollapsed, sidebarPreviewCollapsed]) => (active && (!sidebarCollapsed || !sidebarPreviewCollapsed))),
|
map(([active, sidebarCollapsed, sidebarPreviewCollapsed]) => (active && (!sidebarCollapsed || !sidebarPreviewCollapsed))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
<div class="ds-menu-item-wrapper text-md-center"
|
<div class="ds-menu-item-wrapper text-md-center"
|
||||||
[id]="'expandable-navbar-section-' + section.id"
|
[id]="'expandable-navbar-section-' + section.id"
|
||||||
(mouseenter)="onMouseEnter($event, isActive)"
|
(mouseenter)="onMouseEnter($event)"
|
||||||
(mouseleave)="onMouseLeave($event, isActive)"
|
(mouseleave)="onMouseLeave($event)"
|
||||||
data-test="navbar-section-wrapper"
|
data-test="navbar-section-wrapper">
|
||||||
*ngVar="(active | async) as isActive">
|
|
||||||
<a href="javascript:void(0);" routerLinkActive="active"
|
<a href="javascript:void(0);" routerLinkActive="active"
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
(keyup.enter)="toggleSection($event)"
|
(keyup.enter)="toggleSection($event)"
|
||||||
@@ -12,18 +11,17 @@
|
|||||||
(keydown.space)="$event.preventDefault()"
|
(keydown.space)="$event.preventDefault()"
|
||||||
aria-haspopup="menu"
|
aria-haspopup="menu"
|
||||||
data-test="navbar-section-toggler"
|
data-test="navbar-section-toggler"
|
||||||
[attr.aria-expanded]="isActive"
|
[attr.aria-expanded]="(active$ | async).valueOf()"
|
||||||
[attr.aria-controls]="expandableNavbarSectionId(section.id)"
|
[attr.aria-controls]="expandableNavbarSectionId(section.id)"
|
||||||
class="d-flex flex-row flex-nowrap align-items-center gapx-1 ds-menu-toggler-wrapper"
|
class="d-flex flex-row flex-nowrap align-items-center gapx-1 ds-menu-toggler-wrapper"
|
||||||
[class.disabled]="section.model?.disabled">
|
[class.disabled]="section.model?.disabled">
|
||||||
<span class="flex-fill">
|
<span class="flex-fill">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
|
||||||
<!-- <span class="sr-only">{{'nav.expandable-navbar-section-suffix' | translate}}</span>-->
|
|
||||||
</span>
|
</span>
|
||||||
<i class="fas fa-caret-down fa-xs toggle-menu-icon" aria-hidden="true"></i>
|
<i class="fas fa-caret-down fa-xs toggle-menu-icon" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
<div @slide *ngIf="isActive" (click)="deactivateSection($event)"
|
<div @slide *ngIf="(active$ | async).valueOf() === true" (click)="deactivateSection($event)"
|
||||||
[id]="expandableNavbarSectionId(section.id)"
|
[id]="expandableNavbarSectionId(section.id)"
|
||||||
role="menu"
|
role="menu"
|
||||||
class="dropdown-menu show nav-dropdown-menu m-0 shadow-none border-top-0 px-3 px-md-0 pt-0 pt-md-1">
|
class="dropdown-menu show nav-dropdown-menu m-0 shadow-none border-top-0 px-3 px-md-0 pt-0 pt-md-1">
|
||||||
|
@@ -84,13 +84,12 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
|||||||
/**
|
/**
|
||||||
* When the mouse enters the section toggler activate the menu section
|
* When the mouse enters the section toggler activate the menu section
|
||||||
* @param $event
|
* @param $event
|
||||||
* @param isActive
|
|
||||||
*/
|
*/
|
||||||
onMouseEnter($event: Event, isActive: boolean) {
|
onMouseEnter($event: Event): void {
|
||||||
this.isMobile$.pipe(
|
this.isMobile$.pipe(
|
||||||
first(),
|
first(),
|
||||||
).subscribe((isMobile) => {
|
).subscribe((isMobile) => {
|
||||||
if (!isMobile && !isActive && !this.mouseEntered) {
|
if (!isMobile && !this.active$.value && !this.mouseEntered) {
|
||||||
this.activateSection($event);
|
this.activateSection($event);
|
||||||
}
|
}
|
||||||
this.mouseEntered = true;
|
this.mouseEntered = true;
|
||||||
@@ -100,13 +99,12 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
|||||||
/**
|
/**
|
||||||
* When the mouse leaves the section toggler deactivate the menu section
|
* When the mouse leaves the section toggler deactivate the menu section
|
||||||
* @param $event
|
* @param $event
|
||||||
* @param isActive
|
|
||||||
*/
|
*/
|
||||||
onMouseLeave($event: Event, isActive: boolean) {
|
onMouseLeave($event: Event): void {
|
||||||
this.isMobile$.pipe(
|
this.isMobile$.pipe(
|
||||||
first(),
|
first(),
|
||||||
).subscribe((isMobile) => {
|
).subscribe((isMobile) => {
|
||||||
if (!isMobile && isActive && this.mouseEntered) {
|
if (!isMobile && this.active$.value && this.mouseEntered) {
|
||||||
this.deactivateSection($event);
|
this.deactivateSection($event);
|
||||||
}
|
}
|
||||||
this.mouseEntered = false;
|
this.mouseEntered = false;
|
||||||
|
@@ -37,9 +37,9 @@ import { MenuSection } from '../menu-section.model';
|
|||||||
export class MenuSectionComponent implements OnInit, OnDestroy {
|
export class MenuSectionComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observable that emits whether or not this section is currently active
|
* {@link BehaviorSubject} containing the current state to whether this section is currently active
|
||||||
*/
|
*/
|
||||||
active: Observable<boolean>;
|
active$: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the menu this section resides in
|
* The ID of the menu this section resides in
|
||||||
@@ -72,7 +72,9 @@ export class MenuSectionComponent implements OnInit, OnDestroy {
|
|||||||
* Set initial values for instance variables
|
* Set initial values for instance variables
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.active = this.menuService.isSectionActive(this.menuID, this.section.id).pipe(distinctUntilChanged());
|
this.menuService.isSectionActive(this.menuID, this.section.id).pipe(distinctUntilChanged()).subscribe((isActive: boolean) => {
|
||||||
|
this.active$.next(isActive);
|
||||||
|
});
|
||||||
this.initializeInjectorData();
|
this.initializeInjectorData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user