From 3ee60d85922aaf1f1e77323983738513c4906b57 Mon Sep 17 00:00:00 2001 From: Sergey Andrievskiy Date: Mon, 29 Jul 2019 11:30:20 +0300 Subject: [PATCH 1/2] fix(select): prevent opening of disabled select when clicking on toggle --- src/framework/theme/components/select/select.component.html | 3 ++- 1 file changed, 2 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 }} - +
From 5c175dda97ad260f67f7ac438bdbaf3d56b2ae3e Mon Sep 17 00:00:00 2001 From: Sergey Andrievskiy Date: Mon, 29 Jul 2019 11:52:14 +0300 Subject: [PATCH 2/2] test(select): check disabled select can't be open by clicking --- .../theme/components/select/select.spec.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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', () => {