mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 18:23:31 +00:00
UIF - Prefer signal & change detection (#16940)
This commit is contained in:
@@ -13,6 +13,8 @@ describe("SwitchComponent", () => {
|
||||
let switchComponent: SwitchComponent;
|
||||
let inputEl: HTMLInputElement;
|
||||
|
||||
// TODO: Fix this the next time the file is edited.
|
||||
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
||||
@Component({
|
||||
selector: "test-host",
|
||||
imports: [FormsModule, BitLabel, ReactiveFormsModule, SwitchModule],
|
||||
@@ -70,6 +72,8 @@ describe("SwitchComponent", () => {
|
||||
});
|
||||
|
||||
it("should update checked when selected input changes outside of a form", async () => {
|
||||
// TODO: Fix this the next time the file is edited.
|
||||
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
||||
@Component({
|
||||
selector: "test-selected-host",
|
||||
template: `<bit-switch [selected]="checked"><bit-label>Element</bit-label></bit-switch>`,
|
||||
|
||||
@@ -21,6 +21,8 @@ let nextId = 0;
|
||||
/**
|
||||
* Switch component for toggling between two states. Switch actions are meant to take place immediately and are not to be used in a form where saving/submiting actions are required.
|
||||
*/
|
||||
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
|
||||
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
||||
@Component({
|
||||
selector: "bit-switch",
|
||||
providers: [
|
||||
@@ -46,19 +48,19 @@ export class SwitchComponent implements ControlValueAccessor, AfterViewInit {
|
||||
/**
|
||||
* Model signal for selected state binding when used outside of a form
|
||||
*/
|
||||
protected selected = model(false);
|
||||
protected readonly selected = model(false);
|
||||
|
||||
/**
|
||||
* Model signal for disabled binding when used outside of a form
|
||||
*/
|
||||
protected disabled = model(false);
|
||||
protected disabledReasonText = input<string | null>(null);
|
||||
protected readonly disabled = model(false);
|
||||
protected readonly disabledReasonText = input<string | null>(null);
|
||||
|
||||
private hintComponent = contentChild<BitHintComponent>(BitHintComponent);
|
||||
private readonly hintComponent = contentChild<BitHintComponent>(BitHintComponent);
|
||||
|
||||
private disabledReasonTextId = `bit-switch-disabled-text-${nextId++}`;
|
||||
|
||||
private describedByIds = computed(() => {
|
||||
private readonly describedByIds = computed(() => {
|
||||
const ids: string[] = [];
|
||||
|
||||
if (this.disabledReasonText() && this.disabled()) {
|
||||
|
||||
Reference in New Issue
Block a user