-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dropdown): fix dropdown inside click (#4609)
fixes #1933
- Loading branch information
Showing
10 changed files
with
323 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
demo/src/app/components/+dropdown/demos/inside-click/inside-click.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="btn-group" dropdown [insideClick]="true"> | ||
<button dropdownToggle type="button" class="btn btn-primary dropdown-toggle"> | ||
Button dropdown <span class="caret"></span> | ||
</button> | ||
<ul *dropdownMenu class="dropdown-menu" role="menu"> | ||
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li> | ||
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li> | ||
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li> | ||
<li class="divider dropdown-divider"></li> | ||
<li role="menuitem"><a class="dropdown-item" href="#">Separated link</a> | ||
</li> | ||
</ul> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
demo/src/app/components/+dropdown/demos/inside-click/inside-click.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-dropdown-inside-click', | ||
templateUrl: './inside-click.html' | ||
}) | ||
export class DemoDropdownInsideClickComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { BsDropdownContainerComponent, BsDropdownModule, BsDropdownState } from '../dropdown'; | ||
import { Subject } from 'rxjs'; | ||
import { window } from '../utils'; | ||
|
||
describe('BsDropdownContainerComponent tests', () => { | ||
let fixture: ComponentFixture<BsDropdownContainerComponent>; | ||
let component: BsDropdownContainerComponent; | ||
/* tslint:disable-next-line:no-inferred-empty-object-type */ | ||
const stateSubject = new Subject(); | ||
let fakeService; | ||
|
||
beforeEach(() => { | ||
fakeService = { | ||
isOpenChange: stateSubject.asObservable() | ||
}; | ||
TestBed.configureTestingModule({ | ||
imports: [BsDropdownModule.forRoot()], | ||
providers: [{ provide: BsDropdownState, useValue: fakeService }] | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(BsDropdownContainerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should not be null', () => { | ||
expect(component).not.toBeNull(); | ||
}); | ||
|
||
it('should be call isOpenChange method', () => { | ||
const tempVal = window.__theme; | ||
window.__theme = 'bs4'; | ||
const spy = spyOn((component as any).cd, 'detectChanges'); | ||
|
||
stateSubject.next(true); | ||
fixture.detectChanges(); | ||
|
||
expect(spy).toHaveBeenCalled(); | ||
window.__theme = tempVal; | ||
}); | ||
}); |
Oops, something went wrong.