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

fix(divider): Fix stlying for md-divider inside md-list-item. #5058

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
1 change: 1 addition & 0 deletions src/components/divider/demoBasicUsage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h3>{{item.what}}</h3>
<h4>{{item.who}}</h4>
<p>{{item.notes}}</p>
</div>
<md-button class="md-secondary">Respond</md-button>
<md-divider ng-if="!$last"></md-divider>
</md-list-item>
</md-list>
Expand Down
6 changes: 5 additions & 1 deletion src/components/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ function mdListDirective($mdTheming) {
* </md-list>
* </hljs>
*
* _**Note:** We automatically apply special styling when the inner contents are wrapped inside
* of a `<md-button>` tag. This styling is automatically ignored for `class="md-secondary"` buttons
* and you can include a class of `class="md-exclude"` if you need to use a non-secondary button
* that is inside the list, but does not wrap the contents._
*/
function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {
var proxiedTypes = ['md-checkbox', 'md-switch'];
Expand All @@ -86,7 +90,7 @@ function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {
}
if (hasProxiedElement) {
wrapIn('div');
} else if (!tEl[0].querySelector('md-button')) {
} else if (!tEl[0].querySelector('md-button:not(.md-secondary):not(.md-exclude)')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is .md-exclude documented? At least let's provide some information in the API section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's documented on lines 66-69 above which appear as a note in the directive API docs. Does it need to go somewhere else?

and you can include a class of class="md-exclude" if you need to use a non-secondary button

tEl.addClass('md-no-proxy');
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/components/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ md-list {
}

md-list-item {
// Ensure nested dividers are properly positioned
position: relative;

&.md-proxy-focus.md-focused .md-no-style {
transition: background-color 0.15s linear;
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/list/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,15 @@ describe('mdListItem directive', function() {
expect(listItem.hasClass('md-no-proxy')).toBeFalsy();
});

it('should not detect secondary or excluded md-buttons', function() {
var listItem = setup(
'<md-list-item>' +
' <div>Content Here</div>' +
' <md-button class="md-secondary" ng-click="sayHello()">Hello</md-button>' +
' <md-button class="md-exclude" ng-click="sayHello()">Hello</md-button>' +
'</md-list-item>'
);
expect(listItem.hasClass('md-no-proxy')).toBeTruthy();
});

});