Close sidenav on click (#2156)

It shouldn't stick around after we've clicked on one of the links
This commit is contained in:
gbrodman 2023-09-25 14:43:07 -04:00 committed by GitHub
parent a87c4a31a3
commit 0801679173
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,10 +12,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component } from '@angular/core'; import { Component, ViewChild } from '@angular/core';
import { RegistrarService } from './registrar/registrar.service'; import { RegistrarService } from './registrar/registrar.service';
import { UserDataService } from './shared/services/userData.service'; import { UserDataService } from './shared/services/userData.service';
import { GlobalLoaderService } from './shared/services/globalLoader.service'; import { GlobalLoaderService } from './shared/services/globalLoader.service';
import { NavigationEnd, Router } from '@angular/router';
import { MatSidenav } from '@angular/material/sidenav';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -24,10 +26,15 @@ import { GlobalLoaderService } from './shared/services/globalLoader.service';
}) })
export class AppComponent { export class AppComponent {
renderRouter: boolean = true; renderRouter: boolean = true;
@ViewChild('sidenav')
sidenav!: MatSidenav;
constructor( constructor(
protected registrarService: RegistrarService, protected registrarService: RegistrarService,
protected userDataService: UserDataService, protected userDataService: UserDataService,
protected globalLoader: GlobalLoaderService protected globalLoader: GlobalLoaderService,
protected router: Router
) { ) {
registrarService.activeRegistrarIdChange.subscribe(() => { registrarService.activeRegistrarIdChange.subscribe(() => {
this.renderRouter = false; this.renderRouter = false;
@ -36,4 +43,12 @@ export class AppComponent {
}, 400); }, 400);
}); });
} }
ngAfterViewInit() {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.sidenav.close();
}
});
}
} }