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
This commit is contained in:
@@ -84,7 +84,7 @@ export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionC
|
||||
this.sidebarActiveBg$ = this.variableService.getVariable('--ds-admin-sidebar-active-bg');
|
||||
this.isSidebarCollapsed$ = this.menuService.isMenuCollapsed(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))),
|
||||
);
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<div class="ds-menu-item-wrapper text-md-center"
|
||||
[id]="'expandable-navbar-section-' + section.id"
|
||||
(mouseenter)="onMouseEnter($event, isActive)"
|
||||
(mouseleave)="onMouseLeave($event, isActive)"
|
||||
data-test="navbar-section-wrapper"
|
||||
*ngVar="(active | async) as isActive">
|
||||
(mouseenter)="onMouseEnter($event)"
|
||||
(mouseleave)="onMouseLeave($event)"
|
||||
data-test="navbar-section-wrapper">
|
||||
<a href="javascript:void(0);" routerLinkActive="active"
|
||||
role="menuitem"
|
||||
(keyup.enter)="toggleSection($event)"
|
||||
@@ -12,18 +11,17 @@
|
||||
(keydown.space)="$event.preventDefault()"
|
||||
aria-haspopup="menu"
|
||||
data-test="navbar-section-toggler"
|
||||
[attr.aria-expanded]="isActive"
|
||||
[attr.aria-expanded]="(active$ | async).valueOf()"
|
||||
[attr.aria-controls]="expandableNavbarSectionId(section.id)"
|
||||
class="d-flex flex-row flex-nowrap align-items-center gapx-1 ds-menu-toggler-wrapper"
|
||||
[class.disabled]="section.model?.disabled">
|
||||
<span class="flex-fill">
|
||||
<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>
|
||||
<i class="fas fa-caret-down fa-xs toggle-menu-icon" aria-hidden="true"></i>
|
||||
</a>
|
||||
<div @slide *ngIf="isActive" (click)="deactivateSection($event)"
|
||||
<div @slide *ngIf="(active$ | async).valueOf() === true" (click)="deactivateSection($event)"
|
||||
[id]="expandableNavbarSectionId(section.id)"
|
||||
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">
|
||||
|
@@ -84,13 +84,12 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
||||
/**
|
||||
* When the mouse enters the section toggler activate the menu section
|
||||
* @param $event
|
||||
* @param isActive
|
||||
*/
|
||||
onMouseEnter($event: Event, isActive: boolean) {
|
||||
onMouseEnter($event: Event): void {
|
||||
this.isMobile$.pipe(
|
||||
first(),
|
||||
).subscribe((isMobile) => {
|
||||
if (!isMobile && !isActive && !this.mouseEntered) {
|
||||
if (!isMobile && !this.active$.value && !this.mouseEntered) {
|
||||
this.activateSection($event);
|
||||
}
|
||||
this.mouseEntered = true;
|
||||
@@ -100,13 +99,12 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp
|
||||
/**
|
||||
* When the mouse leaves the section toggler deactivate the menu section
|
||||
* @param $event
|
||||
* @param isActive
|
||||
*/
|
||||
onMouseLeave($event: Event, isActive: boolean) {
|
||||
onMouseLeave($event: Event): void {
|
||||
this.isMobile$.pipe(
|
||||
first(),
|
||||
).subscribe((isMobile) => {
|
||||
if (!isMobile && isActive && this.mouseEntered) {
|
||||
if (!isMobile && this.active$.value && this.mouseEntered) {
|
||||
this.deactivateSection($event);
|
||||
}
|
||||
this.mouseEntered = false;
|
||||
|
@@ -37,9 +37,9 @@ import { MenuSection } from '../menu-section.model';
|
||||
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
|
||||
@@ -72,7 +72,9 @@ export class MenuSectionComponent implements OnInit, OnDestroy {
|
||||
* Set initial values for instance variables
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user