Skip to content

Commit

Permalink
Merge pull request DSpace#2976 from 4Science/DURACOM-253
Browse files Browse the repository at this point in the history
Fix issue with the admin sidebar scrollbar on Firefox/Windows
  • Loading branch information
tdonohue authored Apr 30, 2024
2 parents 0fa5d18 + 44464de commit 41a00e3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/app/admin/admin-sidebar/admin-sidebar.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,9 @@
}
}
}

::ng-deep {
.browser-firefox-windows {
--ds-dark-scrollbar-width: 20px;
}
}
2 changes: 1 addition & 1 deletion src/app/root/root.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ 'root.skip-to-content' | translate }}
</button>

<div class="outer-wrapper" [class.d-none]="shouldShowFullscreenLoader" [@slideSidebarPadding]="{
<div class="outer-wrapper" [class.d-none]="shouldShowFullscreenLoader" [ngClass]="browserOsClasses.asObservable() | async" [@slideSidebarPadding]="{
value: ((isSidebarVisible$ | async) !== true ? 'hidden' : (slideSidebarOver$ | async) ? 'unpinned' : 'pinned'),
params: { collapsedWidth: (collapsedSidebarWidth$ | async), expandedWidth: (expandedSidebarWidth$ | async) }
}">
Expand Down
55 changes: 54 additions & 1 deletion src/app/root/root.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
AsyncPipe,
NgClass,
NgIf,
} from '@angular/common';
import {
Component,
Inject,
Input,
OnInit,
} from '@angular/core';
Expand All @@ -13,6 +15,7 @@ import {
} from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import {
BehaviorSubject,
combineLatest as combineLatestObservable,
Observable,
of,
Expand All @@ -30,6 +33,10 @@ import { environment } from '../../environments/environment';
import { ThemedAdminSidebarComponent } from '../admin/admin-sidebar/themed-admin-sidebar.component';
import { getPageInternalServerErrorRoute } from '../app-routing-paths';
import { ThemedBreadcrumbsComponent } from '../breadcrumbs/themed-breadcrumbs.component';
import {
NativeWindowRef,
NativeWindowService,
} from '../core/services/window.service';
import { ThemedFooterComponent } from '../footer/themed-footer.component';
import { ThemedHeaderNavbarWrapperComponent } from '../header-nav-wrapper/themed-header-navbar-wrapper.component';
import { slideSidebarPadding } from '../shared/animations/slide';
Expand All @@ -47,7 +54,20 @@ import { SystemWideAlertBannerComponent } from '../system-wide-alert/alert-banne
styleUrls: ['./root.component.scss'],
animations: [slideSidebarPadding],
standalone: true,
imports: [TranslateModule, ThemedAdminSidebarComponent, SystemWideAlertBannerComponent, ThemedHeaderNavbarWrapperComponent, ThemedBreadcrumbsComponent, NgIf, ThemedLoadingComponent, RouterOutlet, ThemedFooterComponent, NotificationsBoardComponent, AsyncPipe],
imports: [
TranslateModule,
ThemedAdminSidebarComponent,
SystemWideAlertBannerComponent,
ThemedHeaderNavbarWrapperComponent,
ThemedBreadcrumbsComponent,
NgIf,
NgClass,
ThemedLoadingComponent,
RouterOutlet,
ThemedFooterComponent,
NotificationsBoardComponent,
AsyncPipe,
],
})
export class RootComponent implements OnInit {
theme: Observable<ThemeConfig> = of({} as any);
Expand All @@ -58,6 +78,8 @@ export class RootComponent implements OnInit {
notificationOptions: INotificationBoardOptions;
models: any;

browserOsClasses = new BehaviorSubject<string[]>([]);

/**
* Whether or not to show a full screen loader
*/
Expand All @@ -73,11 +95,23 @@ export class RootComponent implements OnInit {
private cssService: CSSVariableService,
private menuService: MenuService,
private windowService: HostWindowService,
@Inject(NativeWindowService) private _window: NativeWindowRef,
) {
this.notificationOptions = environment.notifications;
}

ngOnInit() {
const browserName = this.getBrowserName();
if (browserName) {
const browserOsClasses = new Array<string>();
browserOsClasses.push(`browser-${browserName}`);
const osName = this.getOSName();
if (osName) {
browserOsClasses.push(`browser-${browserName}-${osName}`);
}
this.browserOsClasses.next(browserOsClasses);
}

this.isSidebarVisible$ = this.menuService.isMenuVisibleWithVisibleSections(MenuID.ADMIN);

this.expandedSidebarWidth$ = this.cssService.getVariable('--ds-admin-sidebar-total-width').pipe(
Expand Down Expand Up @@ -108,4 +142,23 @@ export class RootComponent implements OnInit {
mainContent.focus();
}
}

getBrowserName(): string {
const userAgent = this._window.nativeWindow.navigator.userAgent;
if (/Firefox/.test(userAgent)) {
return 'firefox';
}
if (/Safari/.test(userAgent)) {
return 'safari';
}
return undefined;
}

getOSName(): string {
const userAgent = this._window.nativeWindow.navigator.userAgent;
if (/Windows/.test(userAgent)) {
return 'windows';
}
return undefined;
}
}
16 changes: 15 additions & 1 deletion src/themes/custom/app/root/root.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AsyncPipe,
NgClass,
NgIf,
} from '@angular/common';
import { Component } from '@angular/core';
Expand All @@ -24,7 +25,20 @@ import { SystemWideAlertBannerComponent } from '../../../../app/system-wide-aler
templateUrl: '../../../../app/root/root.component.html',
animations: [slideSidebarPadding],
standalone: true,
imports: [TranslateModule, ThemedAdminSidebarComponent, SystemWideAlertBannerComponent, ThemedHeaderNavbarWrapperComponent, ThemedBreadcrumbsComponent, NgIf, ThemedLoadingComponent, RouterOutlet, ThemedFooterComponent, NotificationsBoardComponent, AsyncPipe],
imports: [
TranslateModule,
ThemedAdminSidebarComponent,
SystemWideAlertBannerComponent,
ThemedHeaderNavbarWrapperComponent,
ThemedBreadcrumbsComponent,
NgIf,
NgClass,
ThemedLoadingComponent,
RouterOutlet,
ThemedFooterComponent,
NotificationsBoardComponent,
AsyncPipe,
],
})
export class RootComponent extends BaseComponent {

Expand Down

0 comments on commit 41a00e3

Please sign in to comment.