diff --git a/apps/browser/src/platform/popup/layout/popup-header.component.html b/apps/browser/src/platform/popup/layout/popup-header.component.html index 55caf1b91e7..e866ba4e81f 100644 --- a/apps/browser/src/platform/popup/layout/popup-header.component.html +++ b/apps/browser/src/platform/popup/layout/popup-header.component.html @@ -9,7 +9,7 @@ *ngIf="showBackButton" [title]="'back' | i18n" [ariaLabel]="'back' | i18n" - (click)="back()" + [bitAction]="backAction" >

{{ pageTitle }}

diff --git a/apps/browser/src/platform/popup/layout/popup-header.component.ts b/apps/browser/src/platform/popup/layout/popup-header.component.ts index f2f8eb95af0..1b491ea881c 100644 --- a/apps/browser/src/platform/popup/layout/popup-header.component.ts +++ b/apps/browser/src/platform/popup/layout/popup-header.component.ts @@ -3,13 +3,18 @@ import { CommonModule, Location } from "@angular/common"; import { Component, Input } from "@angular/core"; import { JslibModule } from "@bitwarden/angular/jslib.module"; -import { IconButtonModule, TypographyModule } from "@bitwarden/components"; +import { + AsyncActionsModule, + FunctionReturningAwaitable, + IconButtonModule, + TypographyModule, +} from "@bitwarden/components"; @Component({ selector: "popup-header", templateUrl: "popup-header.component.html", standalone: true, - imports: [TypographyModule, CommonModule, IconButtonModule, JslibModule], + imports: [TypographyModule, CommonModule, IconButtonModule, JslibModule, AsyncActionsModule], }) export class PopupHeaderComponent { /** Display the back button, which uses Location.back() to go back one page in history */ @@ -26,9 +31,15 @@ export class PopupHeaderComponent { /** Title string that will be inserted as an h1 */ @Input({ required: true }) pageTitle: string; - constructor(private location: Location) {} - - back() { + /** + * Async action that occurs when clicking the back button + * + * If unset, will call `location.back()` + **/ + @Input() + backAction: FunctionReturningAwaitable = async () => { this.location.back(); - } + }; + + constructor(private location: Location) {} } diff --git a/libs/components/src/index.ts b/libs/components/src/index.ts index 9e9329b2158..6881d801e0f 100644 --- a/libs/components/src/index.ts +++ b/libs/components/src/index.ts @@ -35,4 +35,4 @@ export * from "./tabs"; export * from "./toast"; export * from "./toggle-group"; export * from "./typography"; -export * from "./utils/i18n-mock.service"; +export * from "./utils"; diff --git a/libs/components/src/utils/index.ts b/libs/components/src/utils/index.ts new file mode 100644 index 00000000000..afadd6b3b41 --- /dev/null +++ b/libs/components/src/utils/index.ts @@ -0,0 +1,2 @@ +export * from "./function-to-observable"; +export * from "./i18n-mock.service";