Skip to content

Commit

Permalink
fix(accordion): rename change event to avoid conflicts
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the `change` event on the accordion level was renamed to `panelChange`.
Before:

`<ngb-accordion (change)="...">`

after:

`<ngb-accordion (panelChange)="...">`

Fixes #751

Closes #756
  • Loading branch information
pkozlowski-opensource committed Sep 17, 2016
1 parent 401fcfa commit 21eb610
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
@@ -1,4 +1,4 @@
<ngb-accordion (change)="beforeChange($event)">
<ngb-accordion (panelChange)="beforeChange($event)">
<ngb-panel id="1" title="Simple">
<template ngbPanelContent>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia
Expand Down
2 changes: 1 addition & 1 deletion src/accordion/accordion.spec.ts
Expand Up @@ -33,7 +33,7 @@ function expectOpenPanels(nativeEl: HTMLElement, openPanelsDef: boolean[]) {
describe('ngb-accordion', () => {
let html = `
<ngb-accordion #acc="ngbAccordion" [closeOthers]="closeOthers" [activeIds]="activeIds"
(change)="changeCallback($event)" [type]="classType">
(panelChange)="changeCallback($event)" [type]="classType">
<ngb-panel *ngFor="let panel of panels" [id]="panel.id" [disabled]="panel.disabled" [type]="panel.type">
<template ngbPanelTitle>{{panel.title}}</template>
<template ngbPanelContent>{{panel.content}}</template>
Expand Down
5 changes: 3 additions & 2 deletions src/accordion/accordion.ts
Expand Up @@ -127,7 +127,7 @@ export class NgbAccordion implements AfterContentChecked {
/**
* A panel change event fired right before the panel toggle happens. See NgbPanelChangeEvent for payload details
*/
@Output() change = new EventEmitter<NgbPanelChangeEvent>();
@Output() panelChange = new EventEmitter<NgbPanelChangeEvent>();

/**
* A map that stores each panel state
Expand All @@ -154,7 +154,8 @@ export class NgbAccordion implements AfterContentChecked {
const nextState = !this._states.get(panelId);
let defaultPrevented = false;

this.change.emit({panelId: panelId, nextState: nextState, preventDefault: () => { defaultPrevented = true; }});
this.panelChange.emit(
{panelId: panelId, nextState: nextState, preventDefault: () => { defaultPrevented = true; }});

if (!defaultPrevented) {
this._states.set(panelId, nextState);
Expand Down

0 comments on commit 21eb610

Please sign in to comment.