Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(datepicker): check trigger strategy is defined before destroying #2011

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -259,7 +259,9 @@ export abstract class NbBasePicker<D, T, P>
this.ref.dispose();
}

this.triggerStrategy.destroy();
if (this.triggerStrategy) {
this.triggerStrategy.destroy();
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/framework/theme/components/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ describe('nb-datepicker', () => {
input = fixture.nativeElement.querySelector('input');
});

it('should not throw when destroyed right after creation', () => {
const picker = TestBed.createComponent(NbDatepickerComponent).componentInstance;
expect(picker.ngOnDestroy.bind(picker)).not.toThrow();
});

it('should render calendar', () => {
showDatepicker();
const calendar = overlay.querySelector('nb-calendar');
Expand Down