Skip to content

Commit

Permalink
fix(button): apply css for buttons w/ ngIf
Browse files Browse the repository at this point in the history
Closes #5927
  • Loading branch information
adamdbradley committed Jul 5, 2016
1 parent cac1d4f commit 816a648
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/components/backdrop/backdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Directive, ElementRef, Input } from '@angular/core';
import { AppRoot } from '../app/app';
import { isTrueProperty } from '../../util/util';

const DISABLE_SCROLL = 'disable-scroll';

/**
* @private
Expand Down
13 changes: 3 additions & 10 deletions src/components/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ export class Button {
* @private
*/
setRole(val: string) {
this._assignCss(false);
this._role = val;
this._readIcon(this._elementRef.nativeElement);
this._assignCss(true);
}

/**
Expand Down Expand Up @@ -350,16 +353,6 @@ export class Button {
}
}

/**
* @private
*/
static setRoles(contentButtonChildren: any, role: string) {
let buttons = contentButtonChildren.toArray();
buttons.forEach((button: any) => {
button.setRole(role);
});
}

}

const BUTTON_SIZE_ATTRS = ['large', 'small', 'default'];
Expand Down
1 change: 1 addition & 0 deletions src/components/button/test/dynamic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class E2EPage {
myColor1: string;
myColor2: string;
multiColor: Array<string>;
showIf: boolean = true;

constructor() {
this.reset();
Expand Down
3 changes: 3 additions & 0 deletions src/components/button/test/dynamic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<ion-toolbar>
<ion-buttons start>
<button danger *ngIf="showIf">ngIf</button>
<button [color]="isDestructive ? 'danger' : 'primary'" [outline]="isOutline">Outline</button>
</ion-buttons>
<ion-title>Default Buttons</ion-title>
Expand All @@ -25,6 +26,8 @@
<button block [color]="multiColor" [outline]="isClicked" [round]="isCustom" (click)="toggle()">Multicolor Outline (Toggle)</button>
<button block [color]="multiColor" [clear]="isClicked" [round]="isCustom" (click)="toggle()">Multicolor Clear (Toggle)</button>
<hr/>
<button block outline danger (click)="showIf = !showIf">Toggle Header</button>
<hr/>
<button block outline danger (click)="unify()" class="e2eButtonDynamicUnify">Unify all buttons</button>
<button block clear danger (click)="reset()">Reset all buttons</button>

Expand Down
4 changes: 3 additions & 1 deletion src/components/toolbar/toolbar-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export class ToolbarItem {
@ContentChildren(Button)
set _buttons(buttons: any) {
if (this.inToolbar) {
Button.setRoles(buttons, 'bar-button');
buttons.forEach((button: Button) => {
button.setRole('bar-button');
});
}
}
}

0 comments on commit 816a648

Please sign in to comment.