Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit e96293a

Browse files
devversionandrewseguin
authored andcommitted
fix(dialog): re-add md-actions deprecation class. (#10318)
* Re-adds the previously removed `md-actions` class for dialogs. This class needs to be still available for some applications.
1 parent 2c9a5cc commit e96293a

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/components/dialog/dialog.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,19 @@ function MdDialogProvider($$interimElementProvider) {
749749
return dialogPopIn(element, options)
750750
.then(function() {
751751
lockScreenReader(element, options);
752+
warnDeprecatedActions();
752753
focusOnOpen();
753754
});
754755

756+
/**
757+
* Check to see if they used the deprecated .md-actions class and log a warning
758+
*/
759+
function warnDeprecatedActions() {
760+
if (element[0].querySelector('.md-actions')) {
761+
$log.warn('Using a class of md-actions is deprecated, please use <md-dialog-actions>.');
762+
}
763+
}
764+
755765
/**
756766
* For alerts, focus on content... otherwise focus on
757767
* the close button (or equivalent)

src/components/dialog/dialog.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ md-dialog {
8080
}
8181
}
8282

83-
md-dialog-actions {
83+
.md-actions, md-dialog-actions {
8484
display: flex;
8585
order: 2;
8686
box-sizing: border-box;
@@ -100,7 +100,7 @@ md-dialog {
100100
}
101101
}
102102
&.md-content-overflow {
103-
md-dialog-actions {
103+
.md-actions, md-dialog-actions {
104104
border-top-width: 1px;
105105
border-top-style: solid;
106106
}

src/components/dialog/dialog.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,25 @@ describe('$mdDialog', function() {
12731273
expect($document.activeElement).toBe(parent[0].querySelector('#focus-target'));
12741274
}));
12751275

1276+
it('should warn if the deprecated .md-actions class is used', inject(function($mdDialog, $rootScope, $log, $timeout) {
1277+
spyOn($log, 'warn');
1278+
1279+
var parent = angular.element('<div>');
1280+
$mdDialog.show({
1281+
template:
1282+
'<md-dialog>' +
1283+
'<div class="md-actions">' +
1284+
'<button class="md-button">Ok good</button>' +
1285+
'</div>' +
1286+
'</md-dialog>',
1287+
parent: parent
1288+
});
1289+
1290+
runAnimation();
1291+
1292+
expect($log.warn).toHaveBeenCalled();
1293+
}));
1294+
12761295
it('should only allow one open at a time', inject(function($mdDialog, $rootScope, $animate) {
12771296
var parent = angular.element('<div>');
12781297
$mdDialog.show({

0 commit comments

Comments
 (0)