Skip to content

Commit

Permalink
fix(datepicker): check trigger strategy is defined before destroying (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
CandidCodingCanary authored and yggg committed Oct 10, 2019
1 parent 4114ad1 commit a678e60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit a678e60

Please sign in to comment.