Skip to content

Commit

Permalink
fix(accordion): a tag replaced with div, so preventDefault() was remo…
Browse files Browse the repository at this point in the history
…ved from toggleOpen

fixes #1512
  • Loading branch information
valorkin committed Jan 18, 2017
1 parent 7f3e00d commit d352962
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/accordion/accordion-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import { AccordionComponent } from './accordion.component';
<div class="panel card" [ngClass]="panelClass">
<div class="panel-heading card-header" role="tab" (click)="toggleOpen($event)">
<div class="panel-title card-title">
<a href role="button" class="accordion-toggle" [attr.aria-expanded]="isOpen">
<div role="button" class="accordion-toggle" [attr.aria-expanded]="isOpen">
<div *ngIf="heading"[ngClass]="{'text-muted': isDisabled}">{{heading}}</div>
<ng-content select="[accordion-heading]"></ng-content>
</a>
</div>
</div>
</div>
<div class="panel-collapse collapse" role="tabpanel" [collapse]="!isOpen">
Expand Down Expand Up @@ -75,7 +75,6 @@ export class AccordionPanelComponent implements OnInit, OnDestroy {
}

public toggleOpen(event: Event): any {
event.preventDefault();
if (!this.isDisabled) {
this.isOpen = !this.isOpen;
}
Expand Down
6 changes: 3 additions & 3 deletions src/spec/accordion.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ describe('Component: Accordion', () => {
});

it('should have the appropriate heading', () => {
const titles = Array.from(element.querySelectorAll('.panel-heading a span'));
const titles = Array.from(element.querySelectorAll('.panel-heading .accordion-toggle span'));
titles.forEach((title:HTMLElement, idx:number) => expect(hasTitle(title, `Panel ${idx + 1}`)).toBe(true));
});

it('should only open one at a time', () => {
const headingLinks = element.querySelectorAll('.panel-title a');
const headingLinks = element.querySelectorAll('.accordion-toggle');

headingLinks[0].click();
fixture.detectChanges();
Expand All @@ -132,7 +132,7 @@ describe('Component: Accordion', () => {
it('should not open disabled panels from click', () => {
context.panels[0].isDisabled = true;
fixture.detectChanges();
const headingLinks = element.querySelectorAll('.panel-title a');
const headingLinks = element.querySelectorAll('.panel-title .accordion-toggle');
headingLinks[0].click();
fixture.detectChanges();
expectOpenPanels(element, [false, false, false]);
Expand Down

0 comments on commit d352962

Please sign in to comment.