diff --git a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts index 945f56821d2..05590a27f9a 100644 --- a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts +++ b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.spec.ts @@ -115,7 +115,13 @@ describe("CustomFieldsComponent", () => { value: true, newField: false, }, - { linkedId: 1, name: "linked label", type: FieldType.Linked, value: null, newField: false }, + { + linkedId: 1, + name: "linked label", + type: FieldType.Linked, + value: null, + newField: false, + }, ]); }); @@ -132,6 +138,19 @@ describe("CustomFieldsComponent", () => { expect(button).toBeFalsy(); }); + it("should disable the hidden field input when `viewPassword` is false", () => { + originalCipherView.viewPassword = false; + originalCipherView.fields = mockFieldViews; + + component.ngOnInit(); + + fixture.detectChanges(); + + const input = fixture.debugElement.query(By.css('[data-testid="custom-hidden-field"]')); + + expect(input.nativeElement.disabled).toBe(true); + }); + it("when `viewPassword` is true the user can see the view toggle option", () => { originalCipherView.viewPassword = true; originalCipherView.fields = mockFieldViews; diff --git a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.ts b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.ts index f17432a993b..1b3b9009946 100644 --- a/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.ts +++ b/libs/vault/src/cipher-form/components/custom-fields/custom-fields.component.ts @@ -158,20 +158,23 @@ export class CustomFieldsComponent implements OnInit, AfterViewInit { value = field.value === "true" ? true : false; } - this.fields.push( - this.formBuilder.group({ - type: field.type, - name: field.name, - value: value, - linkedId: field.linkedId, - newField: false, - }), - ); - }); + const customField = this.formBuilder.group({ + type: field.type, + name: field.name, + value: value, + linkedId: field.linkedId, + newField: false, + }); - if (!this.cipherFormContainer.originalCipherView?.viewPassword) { - this.customFieldsForm.disable(); - } + if ( + field.type === FieldType.Hidden && + !this.cipherFormContainer.originalCipherView?.viewPassword + ) { + customField.controls.value.disable(); + } + + this.fields.push(customField); + }); // Disable the form if in partial-edit mode // Must happen after the initial fields are populated