1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

[PM-2102] Implement logic to keep row control enable/disable status in sync with the access item properties whenever the parent control is enabled/disabled (#5433)

Angular 15 introduced a breaking change that calls setDisabledState() whenever a CVA is added. This was re-enabling all the internal form group rows (even those that should have remained disabled).
This commit is contained in:
Shane Melton
2023-05-18 10:32:18 -07:00
committed by GitHub
parent 3da7fc7cb3
commit 3f7a63b2c6
2 changed files with 66 additions and 21 deletions

View File

@@ -198,4 +198,18 @@ export class FormSelectionList<
this.selectItem(selectedItem.id, selectedItem);
}
}
/**
* Helper method to iterate over each "selected" form control and its corresponding item
* @param fn - The function to call for each form control and its corresponding item
*/
forEachControlItem(
fn: (control: AbstractControl<Partial<TControlValue>, TControlValue>, value: TItem) => void
) {
for (let i = 0; i < this.formArray.length; i++) {
// The selectedItems array and formArray are explicitly kept in sync,
// so we can safely assume the index of the form control and item are the same
fn(this.formArray.at(i), this.selectedItems[i]);
}
}
}