mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
avoid setting hasNavigated for the initial route
This commit is contained in:
@@ -1618,7 +1618,9 @@ export default class MainBackground {
|
|||||||
// Set route of the popup before attempting to open it.
|
// Set route of the popup before attempting to open it.
|
||||||
// If the vault is locked, this won't have an effect as the auth guards will
|
// If the vault is locked, this won't have an effect as the auth guards will
|
||||||
// redirect the user to the login page.
|
// redirect the user to the login page.
|
||||||
await browserAction.setPopup({ popup: "popup/index.html#/at-risk-passwords" });
|
await browserAction.setPopup({
|
||||||
|
popup: "popup/index.html#/at-risk-passwords?initialRoute=true",
|
||||||
|
});
|
||||||
|
|
||||||
await this.openPopup();
|
await this.openPopup();
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,14 @@ export class PopupRouterCacheService {
|
|||||||
this.router.events
|
this.router.events
|
||||||
.pipe(
|
.pipe(
|
||||||
filter((event) => event instanceof NavigationEnd),
|
filter((event) => event instanceof NavigationEnd),
|
||||||
tap(() => {
|
tap((event: NavigationEnd) => {
|
||||||
|
// Add ability to navigate back to the vault if the initial route query param is set
|
||||||
|
// Without this logic, if the initial route tries to navigate back without a history,
|
||||||
|
// location.back won't navigate at all.
|
||||||
|
if (event.url.includes("initialRoute=true")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// `Location.back()` can now be called successfully
|
// `Location.back()` can now be called successfully
|
||||||
this.hasNavigated = true;
|
this.hasNavigated = true;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -120,4 +120,14 @@ describe("Popup router cache guard", () => {
|
|||||||
|
|
||||||
expect(await firstValueFrom(service.history$())).toEqual(["/a"]);
|
expect(await firstValueFrom(service.history$())).toEqual(["/a"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not set `hasNavigated` flag when the `initialRoute` query param is set", async () => {
|
||||||
|
expect(service["hasNavigated"]).toBe(false);
|
||||||
|
|
||||||
|
await router.navigate(["a"], { queryParams: { initialRoute: true } });
|
||||||
|
|
||||||
|
await flushPromises();
|
||||||
|
|
||||||
|
expect(service["hasNavigated"]).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<popup-page [loading]="loading$ | async">
|
<popup-page [loading]="loading$ | async">
|
||||||
<popup-header
|
<popup-header slot="header" [pageTitle]="'atRiskPasswords' | i18n" showBackButton>
|
||||||
slot="header"
|
|
||||||
[pageTitle]="'atRiskPasswords' | i18n"
|
|
||||||
showBackButton
|
|
||||||
[backAction]="navigateToVault.bind(this)"
|
|
||||||
>
|
|
||||||
<ng-container slot="end">
|
<ng-container slot="end">
|
||||||
<app-pop-out></app-pop-out>
|
<app-pop-out></app-pop-out>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -223,13 +223,4 @@ export class AtRiskPasswordsComponent implements OnInit {
|
|||||||
this.launchingCipher.set(null);
|
this.launchingCipher.set(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* This page can be the first page the user sees when the extension launches,
|
|
||||||
* which can conflict with the `PopupRouterCacheService`. This replaces the
|
|
||||||
* built-in back button behavior so the user always navigates to the vault.
|
|
||||||
*/
|
|
||||||
protected async navigateToVault() {
|
|
||||||
await this.router.navigate(["/tabs/vault"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user