1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

[SM-525] Fix projects not being active when on subroute (#4815)

* Move overview to separate route. Change nav-item to use subset instead of exact

* Add support for setting exactMatch in nav-item and nav-group

* Change default to subset
This commit is contained in:
Oscar Hinton 2023-02-21 19:04:35 +01:00 committed by GitHub
parent 3305c808d1
commit 72283d0a35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -5,6 +5,7 @@
icon="bwi-business" icon="bwi-business"
[route]="['../', activeOrganization.id]" [route]="['../', activeOrganization.id]"
[(open)]="open" [(open)]="open"
[exactMatch]="true"
> >
<ng-container *ngIf="organizations$ | async as organizations"> <ng-container *ngIf="organizations$ | async as organizations">
<bit-nav-item <bit-nav-item

View File

@ -8,6 +8,7 @@
[treeDepth]="treeDepth" [treeDepth]="treeDepth"
(mainContentClicked)="mainContentClicked.emit()" (mainContentClicked)="mainContentClicked.emit()"
[ariaLabel]="ariaLabel" [ariaLabel]="ariaLabel"
[exactMatch]="exactMatch"
> >
<ng-template #button> <ng-template #button>
<button <button

View File

@ -36,6 +36,12 @@ export class NavGroupComponent extends NavBaseComponent implements AfterContentI
*/ */
@Input() @Input()
open = false; open = false;
/**
* if `true`, use `exact` match for path instead of `subset`.
*/
@Input() exactMatch: boolean;
@Output() @Output()
openChange = new EventEmitter<boolean>(); openChange = new EventEmitter<boolean>();

View File

@ -1,4 +1,4 @@
import { Component, HostListener } from "@angular/core"; import { Component, HostListener, Input } from "@angular/core";
import { IsActiveMatchOptions } from "@angular/router"; import { IsActiveMatchOptions } from "@angular/router";
import { BehaviorSubject, map } from "rxjs"; import { BehaviorSubject, map } from "rxjs";
@ -19,13 +19,20 @@ export class NavItemComponent extends NavBaseComponent {
protected get showActiveStyles() { protected get showActiveStyles() {
return this._active && !this.hideActiveStyles; return this._active && !this.hideActiveStyles;
} }
protected readonly rlaOptions: IsActiveMatchOptions = { protected rlaOptions: IsActiveMatchOptions = {
paths: "exact", paths: "subset",
queryParams: "exact", queryParams: "exact",
fragment: "ignored", fragment: "ignored",
matrixParams: "ignored", matrixParams: "ignored",
}; };
/**
* if `true`, use `exact` match for path instead of `subset`.
*/
@Input() set exactMatch(val: boolean) {
this.rlaOptions.paths = val ? "exact" : "subset";
}
/** /**
* The design spec calls for the an outline to wrap the entire element when the template's anchor/button has :focus-visible. * The design spec calls for the an outline to wrap the entire element when the template's anchor/button has :focus-visible.
* Usually, we would use :focus-within for this. However, that matches when a child element has :focus instead of :focus-visible. * Usually, we would use :focus-within for this. However, that matches when a child element has :focus instead of :focus-visible.