mirror of
https://github.com/bitwarden/browser
synced 2026-02-20 03:13:55 +00:00
[PM-24305] Only enable the cipher form when it is disabled (#16259)
* only enable the cipher form when it is disabled * switch to tracking the last emitted state for disabled rather than the form status. The form status can be changed if any child control changes
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
} from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule } from "@angular/forms";
|
||||
import { Subject } from "rxjs";
|
||||
import { BehaviorSubject, Subject } from "rxjs";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { CipherType, SecureNoteType } from "@bitwarden/common/vault/enums";
|
||||
@@ -115,7 +115,7 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
/**
|
||||
* Emitted when the form is enabled
|
||||
*/
|
||||
private formStatusChangeSubject = new Subject<"enabled" | "disabled">();
|
||||
private formStatusChangeSubject = new BehaviorSubject<"enabled" | "disabled" | null>(null);
|
||||
@Output() formStatusChange$ = this.formStatusChangeSubject.asObservable();
|
||||
|
||||
/**
|
||||
@@ -161,9 +161,17 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
this.formStatusChangeSubject.next("disabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the form, only when it is currently disabled.
|
||||
* Child forms could have disabled some of their controls based on
|
||||
* other factors. Enabling the form from this level should only occur
|
||||
* when the form was disabled at this level.
|
||||
*/
|
||||
enableFormFields(): void {
|
||||
this.cipherForm.enable({ emitEvent: false });
|
||||
this.formStatusChangeSubject.next("enabled");
|
||||
if (this.formStatusChangeSubject.getValue() === "disabled") {
|
||||
this.cipherForm.enable({ emitEvent: false });
|
||||
this.formStatusChangeSubject.next("enabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user