Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Fixed dropdown aborting click events #1640

Merged
merged 4 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions src/modules/dropdown/dropdown.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ describe('Dropdown component', () => {
it('should open the menu when clicking the trigger button', fakeAsync(() => {
openPopoverWithButtonClick();
}));

it('should allow clicking of the dropdown tag', fakeAsync(() => {
tick();
fixture.detectChanges();
const dropdownButtonHost = fixture.nativeElement.querySelector('sky-dropdown-button');
const clickSpy = spyOn(component, 'onDropdownClick').and.callThrough();
SkyAppTestUtility.fireDomEvent(dropdownButtonHost, 'click');
tick();
fixture.detectChanges();
expect(clickSpy).toHaveBeenCalled();
}));
});

describe('keyboard interactions', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[alignment]="alignment"
[buttonStyle]="buttonStyle"
[messageStream]="dropdownController"
(click)="onDropdownClick()"
#dropdown>
<sky-dropdown-button>
Show dropdown
Expand Down
2 changes: 2 additions & 0 deletions src/modules/dropdown/fixtures/dropdown.component.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ export class DropdownTestComponent {
this.items = items;
this.changeDetector.detectChanges();
}

public onDropdownClick() {}
}
4 changes: 1 addition & 3 deletions src/modules/popover/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ export class SkyPopoverDirective implements OnChanges, OnDestroy {
Observable
.fromEvent(element, 'click')
.takeUntil(this.idled)
.subscribe((event: MouseEvent) => {
event.preventDefault();
event.stopPropagation();
.subscribe((event: any) => {
this.togglePopover();
});

Expand Down