Skip to content

Commit

Permalink
Add detectChanges() onInit
Browse files Browse the repository at this point in the history
  • Loading branch information
SoyDiego committed Dec 3, 2023
1 parent a5d3bf2 commit ded6445
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr

_suggestions = signal<any>(null);

onModelChange: Function = () => {};
onModelChange: Function = () => { };

onModelTouched: Function = () => {};
onModelTouched: Function = () => { };

timeout: Nullable<any>;

Expand Down Expand Up @@ -844,10 +844,11 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
return !this.virtualScroll;
}

constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) {}
constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) { }

ngOnInit() {
this.id = this.id || UniqueComponentId();
this.cd.detectChanges()
}

ngAfterViewChecked() {
Expand Down Expand Up @@ -973,8 +974,8 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
const matchedOptionIndex =
index < this.visibleOptions().length - 1
? this.visibleOptions()
.slice(index + 1)
.findIndex((option) => this.isValidOption(option))
.slice(index + 1)
.findIndex((option) => this.isValidOption(option))
: -1;

return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
Expand Down Expand Up @@ -1528,9 +1529,9 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
return (
(this.optionGroupLabel
? index -
this.visibleOptions()
.slice(0, index)
.filter((option) => this.isOptionGroup(option)).length
this.visibleOptions()
.slice(0, index)
.filter((option) => this.isOptionGroup(option)).length
: index) + 1
);
}
Expand Down Expand Up @@ -1607,4 +1608,4 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
exports: [AutoComplete, OverlayModule, SharedModule, ScrollerModule, AutoFocusModule],
declarations: [AutoComplete]
})
export class AutoCompleteModule {}
export class AutoCompleteModule { }

0 comments on commit ded6445

Please sign in to comment.