Skip to content

Commit

Permalink
#53: fix Error thrown when using *ngIf on the mat select search compo…
Browse files Browse the repository at this point in the history
…nent, set version to 1.3.1
  • Loading branch information
macjohnny committed Aug 30, 2018
1 parent 1f2439b commit 91672f0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.3.1
* Bugfix: Error thrown when used together with `*ngIf` [#53](https://github.com/bithost-gmbh/ngx-mat-select-search/issues/53)

Thanks to @rhyre for reporting

## 1.3.0
* Enhancement: allow customization of the clear icon [#41](https://github.com/bithost-gmbh/ngx-mat-select-search/issues/41)

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ngx-mat-select-search",
"description": "Library that provides an angular component providing an input field for searching / filtering MatSelect options of the Angular Material library.",
"version": "1.3.0",
"version": "1.3.1",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3>Single selection with custom clear icon</h3>
<p>
<mat-form-field>
<mat-select [formControl]="bankCtrl" placeholder="Bank" #singleSelect>
<ngx-mat-select-search [formControl]="bankFilterCtrl">
<ngx-mat-select-search *ngIf="true" [formControl]="bankFilterCtrl">
<mat-icon ngxMatSelectSearchClear>delete</mat-icon>
</ngx-mat-select-search>
<mat-option *ngFor="let bank of filteredBanks | async" [value]="bank">
Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('AppComponent', () => {
}));
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
Expand Down
14 changes: 10 additions & 4 deletions src/app/mat-select-search/mat-select-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,16 @@ export class MatSelectSearchComponent implements OnInit, OnDestroy, AfterViewIni
this.setOverlayClass();

// update view when available options change
this.matSelect.options.changes
.pipe(takeUntil(this._onDestroy))
.subscribe(() => {
this.changeDetectorRef.markForCheck();
this.matSelect.openedChange
.pipe(
take(1),
takeUntil(this._onDestroy)
).subscribe(() => {
this.matSelect.options.changes
.pipe(takeUntil(this._onDestroy))
.subscribe(() => {
this.changeDetectorRef.markForCheck();
});
});
}

Expand Down

0 comments on commit 91672f0

Please sign in to comment.