Skip to content

Commit 81ddd7f

Browse files
committed
fix(select): add the cssClass passed by the user to the alert for a select
fixes #6835
1 parent 88b637b commit 81ddd7f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/components/alert/alert-component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export class AlertCmp {
103103

104104
if (this.d.cssClass) {
105105
this.d.cssClass.split(' ').forEach(cssClass => {
106-
renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
106+
// Make sure the class isn't whitespace, otherwise it throws exceptions
107+
if (cssClass.trim() !== '') renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
107108
});
108109
}
109110

src/components/select/select.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,18 +301,23 @@ export class Select implements AfterContentInit, ControlValueAccessor, OnDestroy
301301
};
302302
});
303303

304+
var selectCssClass = 'select-alert';
305+
304306
// create the alert instance from our built up alertOptions
305307
overlay = new Alert(this._app, alertOptions);
306308

307309
if (this._multi) {
308310
// use checkboxes
309-
overlay.setCssClass('select-alert multiple-select-alert');
310-
311+
selectCssClass += ' multiple-select-alert';
311312
} else {
312313
// use radio buttons
313-
overlay.setCssClass('select-alert single-select-alert');
314+
selectCssClass += ' single-select-alert';
314315
}
315316

317+
// If the user passed a cssClass for the select, add it
318+
selectCssClass += alertOptions.cssClass ? ' ' + alertOptions.cssClass : '';
319+
overlay.setCssClass(selectCssClass);
320+
316321
overlay.addButton({
317322
text: this.okText,
318323
handler: (selectedValues: any) => {

src/components/select/test/single-value/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class E2EPage {
3030

3131
this.musicAlertOpts = {
3232
title: '1994 Music',
33-
subTitle: 'Select your favorite'
33+
subTitle: 'Select your favorite',
34+
cssClass: 'music-select'
3435
};
3536
}
3637

0 commit comments

Comments
 (0)