mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
force a null value for angular forms as undefined gets forced to null anyway (#16985)
This commit is contained in:
@@ -4,7 +4,7 @@ import { CommonModule } from "@angular/common";
|
||||
import { Component, DestroyRef, Input, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from "@angular/forms";
|
||||
import { concatMap, firstValueFrom, map } from "rxjs";
|
||||
import { concatMap, distinctUntilChanged, firstValueFrom, map } from "rxjs";
|
||||
|
||||
// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop.
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
@@ -236,6 +236,7 @@ export class ItemDetailsSectionComponent implements OnInit {
|
||||
this.itemDetailsForm.controls.organizationId.valueChanges
|
||||
.pipe(
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
distinctUntilChanged(),
|
||||
concatMap(async () => {
|
||||
await this.updateCollectionOptions();
|
||||
this.setFormState();
|
||||
@@ -314,7 +315,10 @@ export class ItemDetailsSectionComponent implements OnInit {
|
||||
|
||||
this.itemDetailsForm.patchValue({
|
||||
name: name ? name : (this.initialValues?.name ?? ""),
|
||||
organizationId: prefillCipher.organizationId, // We do not allow changing ownership of an existing cipher.
|
||||
// We do not allow changing ownership of an existing cipher.
|
||||
// Angular forms do not support `undefined` as a value for a form control,
|
||||
// force `null` if `organizationId` is undefined.
|
||||
organizationId: prefillCipher.organizationId ?? null,
|
||||
folderId: folderId ? folderId : (this.initialValues?.folderId ?? null),
|
||||
collectionIds: [],
|
||||
favorite: prefillCipher.favorite,
|
||||
|
||||
Reference in New Issue
Block a user