Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#53: fix Error thrown when using *ngIf on the mat select search component #54

Merged
merged 1 commit into from
Aug 30, 2018
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
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