Skip to content

Commit

Permalink
fix: Stop propagating clicks from nested icon (#2676)
Browse files Browse the repository at this point in the history
* fix: Stop propagating clicks from nested icon

* fix tests
  • Loading branch information
JKMarkowski committed Jun 17, 2020
1 parent 7f25381 commit c264ff2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Expand Up @@ -171,7 +171,7 @@ describe('NestedItemDirective', () => {
it('Should react to events from icon child', () => {
fixture.detectChanges();
spyOn(nestedItemListDirective, 'toggle');
nestedItemListDirective.contentItem.nestedExpandIcon.onClick();
nestedItemListDirective.contentItem.nestedExpandIcon.onClick(new MouseEvent('click'));
fixture.detectChanges();
expect(nestedItemListDirective.toggle).toHaveBeenCalledWith();
});
Expand All @@ -180,7 +180,7 @@ describe('NestedItemDirective', () => {
fixture.detectChanges();
itemService.popover.handleOpenChange(true);
spyOn(nestedItemPopoverDirective, 'toggle');
nestedItemPopoverDirective.contentItem.nestedExpandIcon.onClick();
nestedItemPopoverDirective.contentItem.nestedExpandIcon.onClick(new MouseEvent('click'));
fixture.detectChanges();
expect(nestedItemPopoverDirective.toggle).toHaveBeenCalledWith();
});
Expand Down
Expand Up @@ -55,7 +55,7 @@ describe('NestedListDirectives', () => {

spyOn((<any>expandIconElement)._itemService.toggle, 'next');

expandIconElement.onClick();
expandIconElement.onClick(new MouseEvent('click'));

fixture.detectChanges();

Expand Down
5 changes: 3 additions & 2 deletions libs/core/src/lib/nested-list/nested-list-directives.ts
Expand Up @@ -111,10 +111,11 @@ export class NestedListExpandIconDirective {
) {}

/** Mouse event handler */
@HostListener('click')
onClick(): void {
@HostListener('click', ['$event'])
onClick(event: MouseEvent): void {
this.expanded = !this.expanded;
this._itemService.toggle.next(this.expanded);
event.stopPropagation();
}

/** Handler for focus events */
Expand Down

0 comments on commit c264ff2

Please sign in to comment.