Skip to content

Commit f7b2ea2

Browse files
committed
fix(button): check for icon and add css after content checked
fixes #6662
1 parent ba3e786 commit f7b2ea2

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

src/components/button/button.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ export class Button {
210210
this._assignCss(true);
211211
}
212212

213+
/**
214+
* @private
215+
*/
216+
ngAfterContentChecked() {
217+
this._readIcon(this._elementRef.nativeElement);
218+
this._assignCss(true);
219+
}
220+
213221
/**
214222
* @private
215223
*/
@@ -256,6 +264,9 @@ export class Button {
256264
}
257265
}
258266

267+
// Remove any classes that are set already
268+
this._setClass(this._icon, false);
269+
259270
if (nodes.length > 1) {
260271
if (nodes[0] === ICON && nodes[1] === TEXT) {
261272
this._icon = 'icon-left';

src/components/item/test/sliding/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ class E2EPage {
1111
items = [];
1212
shouldShow: boolean = true;
1313

14+
moreText: string = "Dynamic More";
15+
archiveText: string = "Dynamic Archive";
16+
1417
constructor(private app: App, private nav: NavController) {
15-
for (let x = 0; x < 20; x++) {
18+
for (let x = 0; x < 5; x++) {
1619
this.items.push(x);
1720
}
1821
}
1922

23+
changeDynamic() {
24+
if (this.moreText.includes("Dynamic")) {
25+
this.moreText = "Changed More";
26+
this.archiveText = "Changed Archive";
27+
} else {
28+
this.moreText = "Dynamic More";
29+
this.archiveText = "Dynamic Archive";
30+
}
31+
}
32+
2033
closeOpened() {
2134
this.list.closeSlidingItems();
2235
}

src/components/item/test/sliding/main.html

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,38 @@ <h3>Ben Sperry</h3>
8383
<button danger (click)="del(item)">
8484
<ion-icon name="trash"></ion-icon>Delete
8585
</button>
86+
</ion-item-options>
87+
</ion-item-sliding>
8688

89+
<ion-item-sliding #item>
90+
<ion-item>
91+
One Line, dynamic option
92+
</ion-item>
93+
<ion-item-options>
94+
<button primary>
95+
<ion-icon name="more"></ion-icon>
96+
{{ moreText }}
97+
</button>
98+
<button secondary (click)="archive(item)">
99+
<ion-icon name="archive"></ion-icon>
100+
{{ archiveText }}
101+
</button>
102+
</ion-item-options>
103+
</ion-item-sliding>
104+
105+
<ion-item-sliding #item>
106+
<ion-item>
107+
One Line, dynamic icon-left option
108+
</ion-item>
109+
<ion-item-options icon-left>
110+
<button primary>
111+
<ion-icon name="more"></ion-icon>
112+
{{ moreText }}
113+
</button>
114+
<button secondary (click)="archive(item)">
115+
<ion-icon name="archive"></ion-icon>
116+
{{ archiveText }}
117+
</button>
87118
</ion-item-options>
88119
</ion-item-sliding>
89120

@@ -111,9 +142,10 @@ <h3>ng-for {{data}}</h3>
111142

112143
</ion-list>
113144

114-
<p>
115-
<button (click)="closeOpened()">Close opened items</button>
116-
</p>
145+
<div padding>
146+
<button block (click)="changeDynamic()">Change Dynamic Options</button>
147+
<button block (click)="closeOpened()">Close Opened Items</button>
148+
</div>
117149

118150
</ion-content>
119151

0 commit comments

Comments
 (0)