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

fix(dialog) md-colors breaking inside of dialogs #11078

Merged
Merged
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: 5 additions & 2 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ function MdDialogProvider($$interimElementProvider) {
var startSymbol = $interpolate.startSymbol();
var endSymbol = $interpolate.endSymbol();
var theme = startSymbol + (options.themeWatch ? '' : '::') + 'theme' + endSymbol;
return '<div class="md-dialog-container" tabindex="-1" md-theme="' + theme + '">' + validatedTemplate(template) + '</div>';
var themeAttr = (options.hasTheme) ? 'md-theme="'+theme+'"': '';
return '<div class="md-dialog-container" tabindex="-1" ' + themeAttr + '>' + validatedTemplate(template) + '</div>';

/**
* The specified template should contain a <md-dialog> wrapper element....
Expand Down Expand Up @@ -854,7 +855,9 @@ function MdDialogProvider($$interimElementProvider) {

var themeCtrl = targetEl && targetEl.controller('mdTheme');

if (!themeCtrl) {
options.hasTheme = (!!themeCtrl);

if (!options.hasTheme) {
return;
}

Expand Down
53 changes: 53 additions & 0 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,59 @@ describe('$mdDialog', function() {
});

describe('theming', function () {

it('should inherit md-theme if the child has a md-theme to inherit',
inject(function ($mdDialog, $mdTheming, $rootScope, $compile) {

var template = '<div id="rawContent">Hello</div>';
var parent = angular.element('<div>');

var button = $compile(
'<button ng-click="showDialog($event)" md-theme="coolTheme">test</button>'
)($rootScope);

$mdTheming(button);

$rootScope.showDialog = function (ev) {
$mdDialog.show({
template: template,
parent: parent,
targetEvent: ev
});
};

button[0].click();

var container = angular.element(parent[0].querySelector('.md-dialog-container'));

expect(container.attr('md-theme')).toEqual('coolTheme');
}));

it('should not set md-theme if the child does not have md-theme to inherit',
inject(function ($mdDialog, $mdTheming, $rootScope, $compile) {

var template = '<div id="rawContent">Hello</div>';
var parent = angular.element('<div>');

var button = $compile('<button ng-click="showDialog($event)">test</button>')($rootScope);

$mdTheming(button);

$rootScope.showDialog = function (ev) {
$mdDialog.show({
template: template,
parent: parent,
targetEvent: ev
});
};

button[0].click();

var container = angular.element(parent[0].querySelector('.md-dialog-container'));

expect(container.attr('md-theme')).toBeUndefined();
}));

it('should inherit targetElement theme', inject(function($mdDialog, $mdTheming, $rootScope, $compile) {
var template = '<div id="rawContent">Hello</div>';
var parent = angular.element('<div>');
Expand Down