mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 12:13:45 +00:00
[PM-18721] disable button during submit process
This commit is contained in:
@@ -17,8 +17,23 @@
|
||||
</div>
|
||||
|
||||
<ng-container bitDialogFooter>
|
||||
<button type="button" bitButton buttonType="primary" (click)="handlePrimaryButtonClick()">
|
||||
{{ "save" | i18n }}
|
||||
<button
|
||||
class="tw-relative"
|
||||
type="button"
|
||||
bitButton
|
||||
buttonType="primary"
|
||||
[disabled]="submitting"
|
||||
(click)="handlePrimaryButtonClick()"
|
||||
>
|
||||
<span
|
||||
[ngClass]="{ 'tw-invisible': !submitting }"
|
||||
class="tw-absolute tw-inset-0 tw-flex tw-items-center tw-justify-center"
|
||||
>
|
||||
<i class="bwi bwi-spinner bwi-lg bwi-spin" aria-hidden="true"></i>
|
||||
</span>
|
||||
<span [ngClass]="{ 'tw-invisible': submitting }">
|
||||
{{ "save" | i18n }}
|
||||
</span>
|
||||
</button>
|
||||
<button type="button" bitButton buttonType="secondary" bitDialogClose>
|
||||
{{ "cancel" | i18n }}
|
||||
|
||||
@@ -67,6 +67,8 @@ export class EmergencyAccessTakeoverDialogComponent implements OnInit {
|
||||
|
||||
inputPasswordFlow = InputPasswordFlow.ChangePasswordDelegation;
|
||||
masterPasswordPolicyOptions?: MasterPasswordPolicyOptions;
|
||||
receivedPasswordInputResult = false;
|
||||
submitting = false;
|
||||
|
||||
constructor(
|
||||
@Inject(DIALOG_DATA) protected dialogData: EmergencyAccessTakeoverDialogData,
|
||||
@@ -91,10 +93,24 @@ export class EmergencyAccessTakeoverDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
protected handlePrimaryButtonClick = async () => {
|
||||
await this.inputPasswordComponent.submit();
|
||||
try {
|
||||
this.submitting = true;
|
||||
await this.inputPasswordComponent.submit();
|
||||
} catch {
|
||||
// Flip to false if submit() throws an error
|
||||
this.submitting = false;
|
||||
}
|
||||
|
||||
// Flip to false if submit() returns early without a PasswordInputResult
|
||||
// emission due to form validation errors or new password doesn't meet org policy reqs.
|
||||
if (!this.receivedPasswordInputResult) {
|
||||
this.submitting = false;
|
||||
}
|
||||
};
|
||||
|
||||
protected async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) {
|
||||
this.receivedPasswordInputResult = Boolean(passwordInputResult);
|
||||
|
||||
try {
|
||||
await this.emergencyAccessService.takeover(
|
||||
this.dialogData.emergencyAccessId,
|
||||
|
||||
Reference in New Issue
Block a user