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

fix(dialog): removed no dialog actions warning #5774

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ function MdDialogProvider($$interimElementProvider) {
*/
function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButtonOrWarn();
var target = $mdUtil.findFocusTarget(element) || findCloseButton();
target.focus();
}

Expand All @@ -564,14 +564,11 @@ function MdDialogProvider($$interimElementProvider) {
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButtonOrWarn() {
function findCloseButton() {
var closeButton = element[0].querySelector('.dialog-close');
if (!closeButton) {
var actionButtons = element[0].querySelectorAll('.md-actions button, md-dialog-actions button');
closeButton = actionButtons[actionButtons.length - 1];
if (actionButtons.length === 0) {
$log.warn('At least one action button is required for <md-dialog-actions>.');
}
}
return angular.element(closeButton);
}
Expand Down
45 changes: 0 additions & 45 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,51 +991,6 @@ describe('$mdDialog', function() {
expect($log.warn).toHaveBeenCalled();
}));

it('should warn if focusOnOpen == true and md-dialog-actions does not contain actions',
inject(function($mdDialog, $rootScope, $log, $timeout) {
spyOn($log, 'warn');

var parent = angular.element('<div>');
$mdDialog.show({
focusOnOpen: true,
template:
'<md-dialog>' +
'<md-dialog-actions>' +
'<p>Why is this here</p>' +
'</md-dialog-actions>' +
'</md-dialog>',
parent: parent
});

runAnimation();

expect($log.warn).toHaveBeenCalled();
}));

// This also covers the case of NOT warning when the deprecated .md-actions class is NOT used
it('should not warn if focusOnOpen == true and md-dialog-actions has actions',
inject(function($mdDialog, $rootScope, $log, $timeout) {
spyOn($log, 'warn');

// Style the parent so <md-backdrop> doesn't fire a warning in Firefox
var parent = angular.element('<div style="position: absolute; left:0;right:0;top:0;bottom:0">');

$mdDialog.show({
focusOnOpen: true,
template:
'<md-dialog>' +
'<md-dialog-actions>' +
'<button class="md-button">Ok good</button>' +
'</md-dialog-actions>' +
'</md-dialog>',
parent: parent
});

runAnimation();

expect($log.warn).not.toHaveBeenCalled();
}));

it('should only allow one open at a time', inject(function($mdDialog, $rootScope, $animate) {
var parent = angular.element('<div>');
$mdDialog.show({
Expand Down