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

Commit 75a565e

Browse files
EladBezalelThomasBurleson
authored andcommitted
fix(dialog): removed no dialog actions warning
It is a valid use-case to have a dialog that you only close programmatically based on some user action. As such, there shouldn't be a warning when there are no md-dialog-actions present. fixes #5767. closes #5774.
1 parent 6260a76 commit 75a565e

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

src/components/dialog/dialog.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ function MdDialogProvider($$interimElementProvider) {
555555
*/
556556
function focusOnOpen() {
557557
if (options.focusOnOpen) {
558-
var target = $mdUtil.findFocusTarget(element) || findCloseButtonOrWarn();
558+
var target = $mdUtil.findFocusTarget(element) || findCloseButton();
559559
target.focus();
560560
}
561561

@@ -565,14 +565,11 @@ function MdDialogProvider($$interimElementProvider) {
565565
*
566566
* If we find no actions at all, log a warning to the console.
567567
*/
568-
function findCloseButtonOrWarn() {
568+
function findCloseButton() {
569569
var closeButton = element[0].querySelector('.dialog-close');
570570
if (!closeButton) {
571571
var actionButtons = element[0].querySelectorAll('.md-actions button, md-dialog-actions button');
572572
closeButton = actionButtons[actionButtons.length - 1];
573-
if (actionButtons.length === 0) {
574-
$log.warn('At least one action button is required for <md-dialog-actions>.');
575-
}
576573
}
577574
return angular.element(closeButton);
578575
}

src/components/dialog/dialog.spec.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -991,51 +991,6 @@ describe('$mdDialog', function() {
991991
expect($log.warn).toHaveBeenCalled();
992992
}));
993993

994-
it('should warn if focusOnOpen == true and md-dialog-actions does not contain actions',
995-
inject(function($mdDialog, $rootScope, $log, $timeout) {
996-
spyOn($log, 'warn');
997-
998-
var parent = angular.element('<div>');
999-
$mdDialog.show({
1000-
focusOnOpen: true,
1001-
template:
1002-
'<md-dialog>' +
1003-
'<md-dialog-actions>' +
1004-
'<p>Why is this here</p>' +
1005-
'</md-dialog-actions>' +
1006-
'</md-dialog>',
1007-
parent: parent
1008-
});
1009-
1010-
runAnimation();
1011-
1012-
expect($log.warn).toHaveBeenCalled();
1013-
}));
1014-
1015-
// This also covers the case of NOT warning when the deprecated .md-actions class is NOT used
1016-
it('should not warn if focusOnOpen == true and md-dialog-actions has actions',
1017-
inject(function($mdDialog, $rootScope, $log, $timeout) {
1018-
spyOn($log, 'warn');
1019-
1020-
// Style the parent so <md-backdrop> doesn't fire a warning in Firefox
1021-
var parent = angular.element('<div style="position: absolute; left:0;right:0;top:0;bottom:0">');
1022-
1023-
$mdDialog.show({
1024-
focusOnOpen: true,
1025-
template:
1026-
'<md-dialog>' +
1027-
'<md-dialog-actions>' +
1028-
'<button class="md-button">Ok good</button>' +
1029-
'</md-dialog-actions>' +
1030-
'</md-dialog>',
1031-
parent: parent
1032-
});
1033-
1034-
runAnimation();
1035-
1036-
expect($log.warn).not.toHaveBeenCalled();
1037-
}));
1038-
1039994
it('should only allow one open at a time', inject(function($mdDialog, $rootScope, $animate) {
1040995
var parent = angular.element('<div>');
1041996
$mdDialog.show({

0 commit comments

Comments
 (0)