From 0542371bfc05457531592fe8bffd1a7e3a5a3215 Mon Sep 17 00:00:00 2001 From: Sergey Andrievskiy Date: Mon, 29 Jul 2019 14:59:47 +0300 Subject: [PATCH] fix(select): prevent opening of disabled select when clicking on toggle (#1865) --- .../components/select/select.component.html | 3 ++- .../theme/components/select/select.spec.ts | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/framework/theme/components/select/select.component.html b/src/framework/theme/components/select/select.component.html index d5317132ac..a35b108a9f 100644 --- a/src/framework/theme/components/select/select.component.html +++ b/src/framework/theme/components/select/select.component.html @@ -17,7 +17,8 @@ {{ placeholder }} - +
diff --git a/src/framework/theme/components/select/select.spec.ts b/src/framework/theme/components/select/select.spec.ts index fb64f4d729..bfe715c122 100644 --- a/src/framework/theme/components/select/select.spec.ts +++ b/src/framework/theme/components/select/select.spec.ts @@ -606,6 +606,32 @@ describe('Component: NbSelectComponent', () => { expect(selectComponent.hostWidth).not.toEqual(selectElement.offsetWidth); expect(selectComponent.hostWidth).toEqual(buttonElement.offsetWidth); }); + + it('should not open when disabled and button clicked', fakeAsync(() => { + const selectFixture = TestBed.createComponent(NbSelectComponent); + selectFixture.componentInstance.disabled = true; + selectFixture.detectChanges(); + const selectButton: HTMLElement = selectFixture.debugElement.query(By.css('button')).nativeElement; + + selectButton.click(); + flush(); + fixture.detectChanges(); + + expect(selectFixture.componentInstance.isOpen).toBeFalsy(); + })); + + it('should not open when disabled and toggle icon clicked', fakeAsync(() => { + const selectFixture = TestBed.createComponent(NbSelectComponent); + selectFixture.componentInstance.disabled = true; + selectFixture.detectChanges(); + const selectToggleIcon: HTMLElement = selectFixture.debugElement.query(By.css('nb-icon')).nativeElement; + + selectToggleIcon.click(); + flush(); + fixture.detectChanges(); + + expect(selectFixture.componentInstance.isOpen).toBeFalsy(); + })); }); describe('NbSelectComponent - falsy values', () => {