Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] Labels reduce their width based on the screen rather than container #2829

Closed
maxime1992 opened this issue Jan 27, 2017 · 9 comments
Closed
Assignees
Labels
help wanted The team would appreciate a PR from the community to address this issue P4 A relatively minor issue that is not relevant to core functions

Comments

@maxime1992
Copy link

Bug, feature request, or proposal:

Probably a bug (?)

What is the current behavior?

Here's my app in desktop mode : (sidenav has a fixed width : 320px)

localhost-4200-workspaces-idwks0

Notice the way tabs are displayed on the left :

image

When I open the app on my mobile :
localhost-4200-workspaces-idwks0 nexus 5x

1 or 2 versions of material2 before, tabs where displaying the same way.
I didn't take the time to open this issue before.

What is the expected behavior?

I'd like to have smaller tabs on desktop mode

What are the steps to reproduce?

Here's the funniest part : I tried to reproduce with a Plunkr : http://plnkr.co/edit/aGPvdK8qUL1jEBWXxYn4?p=preview

It's working as expected and not like on my site.

Still, I'm opening this issue in case there's some edge case you may be aware of.

Feel free to close it as I couldn't reproduce.

I didn't apply custom css so I don't understand where this is coming from.

If you really want to repro my problem, you can launch those commands to setup my project and you'll be running the app in a minute :

git clone https://gitlab.com/victornoel/petals-cockpit.git
git checkout ee685d5
cd petals-cockpit/frontend
yarn
ng serve

Then go to http://localhost:4200/workspaces/idWks0

Which versions of Angular, Material, OS, browsers are affected?

Material 2.0.0-beta.1
Ubuntu 16.10
Chromium 55.0.2883.87

@andrewseguin
Copy link
Contributor

This is due to the CSS rule in tab-header.scss:

@media ($md-xsmall) {
  .md-tab-label {
    min-width: 72px;
  }
}

We say that if the screen is small, then the labels should change their min-width from 160px to 72px. I would say that rather than looking at the screen width, we should look at the tab header width instead.

For now to fix your issue, you can set your own custom CSS rule that always sets the min-width as 72px. We will consider how to modify this rule in the library so that it will use the tab header's width rather than the screen.

@andrewseguin andrewseguin self-assigned this Jan 27, 2017
@andrewseguin andrewseguin changed the title Tabs : Desktop VS Mobile Tabs : Labels shrink based on the screen width rather than the tab header width Jan 27, 2017
@andrewseguin andrewseguin changed the title Tabs : Labels shrink based on the screen width rather than the tab header width Tabs : Labels reduce width based on the screen width rather than the tab header width Jan 27, 2017
@andrewseguin andrewseguin added the help wanted The team would appreciate a PR from the community to address this issue label Jan 27, 2017
@maku
Copy link

maku commented Feb 1, 2017

@andrewseguin I have problems to set the labels width for a specific component.
I tried to define the css class (.md-tab-label) in a css file and defined it for a component via "styleUrls".
But this does not work...
Do you have a suggestion how I am able to do it?

@andrewseguin
Copy link
Contributor

This is an issue with view encapsulation in Angular. The tab component dynamically adds in some of its own templating, and it won't be able to use your CSS defined in your component.

To resolve this, you can either place your styles in a stylesheet outside of your Angular app (this is what I do in my apps), or you can turn off view encapsulation in your component containing the tabs (encapsulation: ViewEncapsulation.None). Both in my opinion are not ideal but it's what we have to work with right now

@andrewseguin
Copy link
Contributor

Additionally, in your case you probably just want to use the md-stretch-tabs feature in tabs: http://plnkr.co/edit/DIjIoK8byvQdaVUsF0Sw?p=preview

@M-a-c
Copy link
Contributor

M-a-c commented Apr 5, 2017

@andrewseguin can you explain what would need to be done to close this issue? The problem seems rather undefined / un-reproducible, are you opening a Pr to close this issue?

@codegastudio
Copy link

@andrewseguin md-stretch-tabs not working to stretch tabs in desktop browser with 2.0.0 beta.6 :/

@christophechevalier
Copy link

christophechevalier commented Jun 30, 2017

Temporary fix :

.html

    <md-tab-group fxFlex md-stretch-tabs>
      <md-tab label="Petals">
        <app-petals-menu-view></app-petals-menu-view>
      </md-tab>

      <md-tab label="Service">
        Some more tab content
      </md-tab>

      <md-tab label="Api">
        Some more tab content
      </md-tab>
    </md-tab-group>

.scss

.mat-sidenav-container > .mat-sidenav > .mat-tab-group > .mat-tab-header > .mat-tab-label-container > .mat-tab-list > .mat-tab-labels {
  .mat-tab-label[role^='tab'] {
    min-width: 72px;
  }
}

Related #5286
Thanks guys ! 🍕

@andrewseguin andrewseguin changed the title Tabs : Labels reduce width based on the screen width rather than the tab header width [Tabs] Labels reduce their width based on the screen rather than container Oct 19, 2017
@andrewseguin andrewseguin added the P4 A relatively minor issue that is not relevant to core functions label Oct 19, 2017
@jelbourn
Copy link
Member

jelbourn commented May 9, 2018

Closing this since I believe it's working as intended; the behavior falls into the category of "do something different on desktop/mobile"

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted The team would appreciate a PR from the community to address this issue P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

7 participants