Skip to content

Commit 8870430

Browse files
feat: on push strategy for combobox
1 parent 8fad690 commit 8870430

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/combobox/combobox.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
AfterContentInit,
1313
HostBinding,
1414
TemplateRef,
15-
OnDestroy
15+
OnDestroy,
16+
ChangeDetectionStrategy,
17+
ChangeDetectorRef
1618
} from "@angular/core";
1719
import { AbstractDropdownView, DropdownService } from "carbon-components-angular/dropdown";
1820
import { ListItem } from "carbon-components-angular/dropdown";
@@ -138,7 +140,6 @@ import { Observable } from "rxjs";
138140
[placeholder]="placeholder"/>
139141
@if (invalid) {
140142
<svg
141-
142143
cdsIcon="warning--filled"
143144
size="16"
144145
class="cds--list-box__invalid-icon">
@@ -222,7 +223,8 @@ import { Observable } from "rxjs";
222223
useExisting: ComboBox,
223224
multi: true
224225
}
225-
]
226+
],
227+
changeDetection: ChangeDetectionStrategy.OnPush
226228
})
227229
export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnDestroy {
228230
/**
@@ -500,7 +502,8 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
500502
constructor(
501503
protected elementRef: ElementRef,
502504
protected dropdownService: DropdownService,
503-
protected i18n: I18n
505+
protected i18n: I18n,
506+
protected cdr: ChangeDetectorRef
504507
) {}
505508

506509
/**
@@ -743,6 +746,8 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
743746
}
744747

745748
document.removeEventListener("click", this.outsideClick, true);
749+
750+
this.cdr.markForCheck();
746751
}
747752

748753
/**
@@ -766,6 +771,8 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
766771
this._dropUp = this._shouldDropUp();
767772
}
768773
}, 0);
774+
775+
this.cdr.markForCheck();
769776
}
770777

771778
/**

0 commit comments

Comments
 (0)