feat(tab): support applying classes to md-tab and reflecting them on the md-tab-item
I need some tabs to be a different color than the rest. I assigned a class to the md-tab element in my markup, but it doesn't get assigned to the final md-tab-item and the styles don't apply to the tab. Shouldn't that class get passed on?
I am facing the same problem. Although there is a unique ID attribute on every md-tab-content, developers still lose the control on these elements. Is there a way to add custom class values to md-tab-content tag?
@evamichalcak @tony0918 The way I was thinking of solving this issue would be that when using the md-tab-label and md-tab-body tags, all attributes would be transferred to their respective md-tab-item and md-tab-content tags. Any thoughts on this?
@robertmesserle That's perfect. But Also from version 0.9.8, there is an additional div which wrap up tab contents. It's hard to add custom class to that div tag as well. Do you have any plan to that? Thanks.
@tony0918 This extra div MAY be temporary - I'd like to remove it, but the alternative solution is much uglier and would take a bit more time to fine tune. Is there any reason that you explicitly need a class on that DIV and not on the parent element?
@robertmesserle That's wonderful. In order to make the content in the tab content to take the rest space of the container, I need to add flex and layout attributes on that element. It's my requirement.
@tony0918 Ah, okay, that makes sense.
Where are we with this? We'd like to write web driver tests for our pages and not being able to set a class or an ID on a tab that we "click" on makes things very difficult and/or fragile (e.g. having to write a selector that includes the child offset of the tab).
Much related to #2254. The solution proposed here by @robertmesserle would close both issues.
This issue is closed as part of our deprecation effort. For details, see our post Spring Cleaning 2016.
@osuritz did you ever figure out a solution for this? We're in exactly the same spot. Trying to write Protractor tests and can't assign a class or ID.
I've moved on to a different project since, but I think at the time we ended up using an offset number in the CSS selector.
On Tue, Jul 25, 2017 at 4:59 AM, mcblum [email protected] wrote:
@osuritz https://github.com/osuritz did you ever figure out a solution for this? We're in exactly the same spot. Trying to write Protractor tests and can't assign a class or ID.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/material/issues/3028#issuecomment-317715721, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4qSDSJtQzAWPR20oeqyJJ4fqT6rIQAks5sRdi8gaJpZM4Eu_O- .
I once wrote a directive which watches the class names of the original <md-tab> element and applies it to the actual item and dummy:
md-tab-class
Maybe this helps someone.
Usage example:
<md-tabs>
<md-tab
ng-repeat="group in ctrl.groups"
md-active="ctrl.activeGroup === group"
ng-class="{
undone: group.$undone,
valid: group.$valid,
invalid: !group.$valid,
active: ctrl.activeGroup === group
}"
md-tab-class
>
<md-tab-label>{{group.title}}</md-tab-label>
</md-tab>
</md-tabs>
Thanks @oemmes this directive works like a charm.
Re-opening this as it effects testability of AngularJS Material applications which is important. We would welcome a PR that resolved this.
Fixed in https://github.com/angular/material/commit/aa30ada04bbd04c2e5fec99dd0b9357098d291db.
@Splaktar Documentation needs update about this feature.
@izerozlu docs were included in the PR. But for some reason it appears that they weren't deployed to https://material.angularjs.org/HEAD/api/directive/mdTab. I'll look into it and verify that they appear when we do the 1.1.11 release.
I opened https://github.com/angular/material/issues/11451 to track this docs deployment issue.
@izerozlu thanks for the heads up. The mdTab docs have been updated.