Skip to content

Commit

Permalink
fix(select): add the cssClass passed by the user to the alert for a s…
Browse files Browse the repository at this point in the history
…elect

fixes #6835
  • Loading branch information
brandyscarney committed Jul 8, 2016
1 parent 88b637b commit 81ddd7f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/alert/alert-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export class AlertCmp {

if (this.d.cssClass) {
this.d.cssClass.split(' ').forEach(cssClass => {
renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
// Make sure the class isn't whitespace, otherwise it throws exceptions
if (cssClass.trim() !== '') renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
});
}

Expand Down
11 changes: 8 additions & 3 deletions src/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,23 @@ export class Select implements AfterContentInit, ControlValueAccessor, OnDestroy
};
});

var selectCssClass = 'select-alert';

// create the alert instance from our built up alertOptions
overlay = new Alert(this._app, alertOptions);

if (this._multi) {
// use checkboxes
overlay.setCssClass('select-alert multiple-select-alert');

selectCssClass += ' multiple-select-alert';
} else {
// use radio buttons
overlay.setCssClass('select-alert single-select-alert');
selectCssClass += ' single-select-alert';
}

// If the user passed a cssClass for the select, add it
selectCssClass += alertOptions.cssClass ? ' ' + alertOptions.cssClass : '';
overlay.setCssClass(selectCssClass);

overlay.addButton({
text: this.okText,
handler: (selectedValues: any) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/select/test/single-value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class E2EPage {

this.musicAlertOpts = {
title: '1994 Music',
subTitle: 'Select your favorite'
subTitle: 'Select your favorite',
cssClass: 'music-select'
};
}

Expand Down

0 comments on commit 81ddd7f

Please sign in to comment.