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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AfterContentInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ContentChildren,
EventEmitter,
Expand Down Expand Up @@ -201,6 +202,8 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte
private propagateControlValueChange?: (value: V[] | undefined) => void;
private propagateControlValueChangeOnTouch?: (value: V[] | undefined) => void;

public constructor(private readonly cdr: ChangeDetectorRef) {}

public ngAfterContentInit(): void {
this.allOptions$ = this.allOptionsList !== undefined ? queryListAndChanges$(this.allOptionsList) : EMPTY;
this.filteredOptions$ = combineLatest([this.allOptions$, this.searchSubject]).pipe(
Expand Down Expand Up @@ -265,6 +268,7 @@ export class MultiSelectComponent<V> implements ControlValueAccessor, AfterConte

public writeValue(value?: V[]): void {
this.setSelection(value ?? []);
this.cdr.markForCheck();
}

public registerOnChange(onChange: (value: V[] | undefined) => void): void {
Expand Down
8 changes: 3 additions & 5 deletions projects/components/src/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
return this.showBorder ? SelectJustify.Left : SelectJustify.Right;
}

public constructor(
private readonly loggerService: LoggerService,
private readonly changeDetector: ChangeDetectorRef
) {}
public constructor(private readonly loggerService: LoggerService, private readonly cdr: ChangeDetectorRef) {}

public ngAfterContentInit(): void {
this.selected$ = this.buildObservableOfSelected();
Expand All @@ -282,7 +279,7 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni

public updateGroupPosition(position: SelectGroupPosition): void {
this.groupPosition = position;
this.changeDetector.markForCheck();
this.cdr.markForCheck();
}

public searchOptions(searchText: string): void {
Expand Down Expand Up @@ -341,6 +338,7 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni

public writeValue(value?: V): void {
this.setSelection(value);
this.cdr.markForCheck();
}

public registerOnChange(onChange: (value: V | undefined) => void): void {
Expand Down
17 changes: 15 additions & 2 deletions projects/components/src/textarea/textarea.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnInit,
Output
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { LoggerService } from '@hypertrace/common';

Expand Down Expand Up @@ -44,7 +52,7 @@ export class TextareaComponent implements ControlValueAccessor, OnInit {
@Output()
public readonly valueChange: EventEmitter<string> = new EventEmitter();

public constructor(private readonly loggerService: LoggerService) {}
public constructor(private readonly loggerService: LoggerService, private readonly cdr: ChangeDetectorRef) {}

public ngOnInit(): void {
// tslint:disable-next-line:strict-type-predicates
Expand All @@ -64,6 +72,7 @@ export class TextareaComponent implements ControlValueAccessor, OnInit {

public writeValue(value?: string): void {
this.value = value;
this.cdr.markForCheck();
}

public registerOnChange(onChange: (value?: string) => void): void {
Expand All @@ -74,6 +83,10 @@ export class TextareaComponent implements ControlValueAccessor, OnInit {
this.propagateControlValueChangeOnTouch = onTouch;
}

public setDisabledState(isDisabled?: boolean): void {
this.disabled = isDisabled ?? false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

you want to add cdr markForCheck here?

Copy link
Contributor Author

@palbizu palbizu Mar 11, 2022

Choose a reason for hiding this comment

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

It seems not necessary to put it here for this component. Disabling is working fine


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