Components: Support multiple classes in MdDialog's panelClass

Created on 7 Aug 2017  路  4Comments  路  Source: angular/components

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

I want MdDialogConfig to have option for panelClass to be an array of classes, like
panelClass: ['custom-container', 'widget-container']

What is the current behavior?

Currently there could be only one panelClass per dialog

What is the use-case or motivation for changing an existing behavior?

I want to add various classes depending on environment, but i have no such option and i have to include all possible combinations into separate classes

has pr

Most helpful comment

@willshowell I believe that is not possible, doing

let config = new MdDialogConfig();
config.panelClass = 'custom-container widget-container';

gives me next error:

ERROR DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('custom-container widget-container') contains HTML space characters, which are not valid in tokens.
    at OverlayRef.webpackJsonpac__name_.5.OverlayRef.attach (http://localhost:8080/site/vendor.bundle.js:51819:34)
    at MdDialog.webpackJsonpac__name_.5.MdDialog._attachDialogContainer (http://localhost:8080/site/vendor.bundle.js:67867:53)
    at MdDialog.webpackJsonpac__name_.5.MdDialog.open (http://localhost:8080/site/vendor.bundle.js:67809:53)

etc.

All 4 comments

Should be able to do

panelClass: 'custom-container widget-container'

That said, I wish all the overlay class api's were NgClass-compatible

@willshowell I believe that is not possible, doing

let config = new MdDialogConfig();
config.panelClass = 'custom-container widget-container';

gives me next error:

ERROR DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('custom-container widget-container') contains HTML space characters, which are not valid in tokens.
    at OverlayRef.webpackJsonpac__name_.5.OverlayRef.attach (http://localhost:8080/site/vendor.bundle.js:51819:34)
    at MdDialog.webpackJsonpac__name_.5.MdDialog._attachDialogContainer (http://localhost:8080/site/vendor.bundle.js:67867:53)
    at MdDialog.webpackJsonpac__name_.5.MdDialog.open (http://localhost:8080/site/vendor.bundle.js:67809:53)

etc.

Oh yeah, you're right. Maybe some combination of this with an isArray check would do it

- this._pane.classList.add(this._state.panelClass);
+ this._pane.classList.add(...this._state.panelClass);

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LoganDupont picture LoganDupont  路  3Comments

alanpurple picture alanpurple  路  3Comments

theunreal picture theunreal  路  3Comments

julianobrasil picture julianobrasil  路  3Comments

shlomiassaf picture shlomiassaf  路  3Comments