question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Tabs] Ink bar is not correctly aligned on init

See original GitHub issue

Bug, feature request, or proposal:

Bug (Some different than https://github.com/angular/material2/issues/3044)

What is the expected behavior?

Highlighter [md-ink-bar] should invalidate position on init app

What is the current behavior?

Misaligned [md-ink-bar]. Please see attached image.

What are the steps to reproduce?

Case 1

  1. Open demo application from material2
  2. Navigate to tabs (Especially for Tab Nav Bar with routing example)
  3. Apply md-stretch-tabs directive for <nav> and apply styles for tab items [md-stretch-tabs] [md-tab-link] { flex-basis: 0; flex-grow: 1; }
  4. Try to expand / collapse application sidebar.

Case 2 (or just apply attached git patch. )

  1. Open demo application from material2
  2. Setup <md-sidenav mode=“side” opened=“true”> for root app container.
  3. Navigate to tabs (Especially for Tab Nav Bar with routing example)
  4. Apply md-stretch-tabs directive for <nav> and apply styles for tab items [md-stretch-tabs] [md-tab-link] { flex-basis: 0; flex-grow: 1; }
  5. Select not first tab
  6. Refresh page

Providing a Plunker (or similar) is the best way to get the team to see your issue. Patch: MD_TabBar_issue.patch.zip

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

Based on up to date sources of material2

Is there anything else we should know?

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:11

github_iconTop GitHub Comments

7reactions
Andermancommented, Mar 16, 2019

I have this workarond

  @ViewChild(MatTabNav) public matTabNav: MatTabNav;
  public ngAfterViewChecked(): void {
    setTimeout(() => this.matTabNav._alignInkBar(), 0);
  }
6reactions
omaracrystalcommented, Sep 10, 2020

I also have ran into this issue. The mat-ink-bar does not recalculate when there is a material side nav with the mode set to “side”. Here is my work around with css (I am hiding the mat-ink-bar and using &:after styling):

  • (add this to your global styles so it takes effect throughout your app)
.mat-tab-label-active {
    .mat-tab-label-content {
      font-weight: bold;
      color: black;

      &:after {
        content: '';
        display: block;
        position: absolute;
        width: 100%;
        height: 2px;
        background: $blue-3;
        right: 0;
        bottom: 0;
      }
   }
}

mat-ink-bar {
  display: none !important;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ink bar under centered tabs not being aligned properly when ...
It seems that setting the sidenav's mode property to push fixes the problem. However, it changes how the components are displayed, ...
Read more >
[Solved]-How to set the Angular material tab's mat-ink-bar to ...
[Solved]-How to set the Angular material tab's mat-ink-bar to take the width of tab ... Ink bar under centered tabs not being aligned...
Read more >
Tabs - Angular Material
Material design tab-group component. Supports basic tab pairs (label + content) and includes animated ink-bar, keyboard navigation, and screen reader.
Read more >
fix(material/tabs): ensure the ink bar realigns when the tab header ...
It uses ResizeObserver to ensure we get notifications about the dimensions of the tabs when they change. The layout change will fire synchronously....
Read more >
Change Log - Ant Design
showSearch . #39531 @YinDongFang; Fix Tabs inkBar not show in StrictMode. ... #39517; Fix Modal hooks not pass ConfigProvider config correctly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found