Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/components/src/input/input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class InputComponent<T extends string | number> implements ControlValueAc
public registerOnTouched(onTouch: (value: T | undefined) => void): void {
this.propagateControlValueChangeOnTouch = onTouch;
}

public setDisabledState(isDisabled?: boolean): void {
this.disabled = isDisabled ?? false;
}
Expand Down
4 changes: 4 additions & 0 deletions projects/components/src/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
this.propagateControlValueChangeOnTouch = onTouch;
}

public setDisabledState(isDisabled?: boolean): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the property is public is there a need for a method to access it?

Copy link
Contributor Author

@palbizu palbizu Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no clear reasons. Probably @anandtiwary can clarify it. I followed the same structure already implemented in the input component to the Control Value Accessor. I will try to find the reason.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is related to ControlValueAccessor interface, this function will be used by reactive form field to set the disabled state using form group itself. We will not pass any [disabled] input in the template while using the select component in the forms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @itssharmasandeep , does it fine to keep it public?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is fine.

this.disabled = isDisabled ?? false;
}

private propagateValueChangeToFormControl(value: V | undefined): void {
this.propagateControlValueChange?.(value);
this.propagateControlValueChangeOnTouch?.(value);
Expand Down