Repository navigation
feat(dialog): custom class option #4718 #4012 - #4722
Conversation
Extend dialog config options to allow custom dialog class. Custom class enables media queries. angular#4718 angular#4012
|
I tried to run unit tests but I am getting chrome disconnected error message so it seems something is wrong with karma config. I've tried to increase timeouts but it didn't help. Also e2e test were failing even before my changes so couldn't test that either. |
|
Would it be possible to support the same syntax as ngClass? e.g. #4629 |
|
@willshowell that would be great though situation here is more complex as pane element is created dynamically so I'd need to handle all different types of class object to add classes with classList.add. I'll try |
|
Ah yes I see. I'm curious why you chose to add the class to the If you instead chose to attach to // dialog-container.ts
@Component({
// ...
host: {
+ '[class]': 'dialogConfig?.dialogClass',
'[class.mat-dialog-container]': 'true',
'[attr.role]': 'dialogConfig?.role',
'[@slideDialog]': '_state',
'(@slideDialog.done)': '_onAnimationDone($event)',
},
})
export class MdDialogContainer extends BasePortalHost { |
| scrollStrategy: ScrollStrategy = new NoopScrollStrategy(); | ||
|
|
||
| /** Custom class to add to the dialog */ | ||
| dialogClass: string = ''; |
There was a problem hiding this comment.
Overlay is the basis for multiple components, not just dialog. I would call this panelClass.
| role?: DialogRole = 'dialog'; | ||
|
|
||
| /** Custom class for the dialog, */ | ||
| dialogClass?: string = ''; |
There was a problem hiding this comment.
Probably call this panelClass as well (this is already DialogConfig, so using the word dialog again on a property is redundant)
| this._attachBackdrop(); | ||
| } | ||
|
|
||
| if (this._state.dialogClass) { |
There was a problem hiding this comment.
There needs to be a unit test for this behavior in the overlay tests
| this._togglePointerEvents(false); | ||
| this._state.scrollStrategy.disable(); | ||
| this._detachments.next(); | ||
| if (this._state.dialogClass) { |
There was a problem hiding this comment.
I don't think removing the class is necessary
|
@willshowell I chose cdk-overlay-pane because when you use width dialog option it's set to that element so I guess that's the right one. |
|
@jbojcic1 understood, and I agree that it keeps it consistent. My personal use cases were for removing the dialog padding and overriding the dialog's max-width (see #4653). But after playing with it some, I see that you get better position control by having the selector on the Thanks for putting this PR together and once it's merged, I'll just use |
Changed custom class config option name. Remove unnecessary class removal on detach. angular#4718 angular#4012
Added missing unit test to check if overlay pane has custom panel class. angular#4718 angular#4012
|
@jelbourn pls check now |
jelbourn
left a comment
There was a problem hiding this comment.
Just a couple last comments
| /** Strategy to be used when handling scroll events while the overlay is open. */ | ||
| scrollStrategy: ScrollStrategy = new NoopScrollStrategy(); | ||
|
|
||
| /** Custom class to add to the dialog */ |
There was a problem hiding this comment.
Comment still says "dialog", should say "overlay pane"
| beforeEach(() => { | ||
| config = new OverlayState(); | ||
| config.panelClass = 'custom-panel-class'; | ||
| }); |
There was a problem hiding this comment.
You don't really need the beforeEach here; you can create the stats and set the class in the test itself because it's only being used once
Change wrong comment. Remove unnecessary beforeEach from test. angular#4718 angular#4012
|
@jelbourn done |
|
FYI, somebody is very much waiting for this merge. |
|
Any update when this will make it into a release? |
|
@jonsamwell not sure. Maybe @jelbourn will know? |
|
Very much looking forward to this 😬 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Extend dialog config options to allow custom dialog class. Custom class enables media queries.