Skip to content

mat-tab-header-pagination displaying incorrectly #17347

Closed

Description

@Anderman

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue

Steps to reproduce:
1.
2.

Expected Behavior

mat-tab-header-pagination should only be displayed when the tabs cannot fit inside the container.

Actual Behavior

image
image
image

A small rounding problem in chrome?

Environment

  • Angular:8.2.8
  • CDK/Material:8.2.1
  • Browser(s):chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): windows10

Activity

  1. Anderman commented on Oct 10, 2019

    @Anderman
    Author

    I found a workaround to fix the bug

    export class ToolbarComponent implements OnInit {
      constructor(public auth: AuthService, private router: Router) { }
      @ViewChild(MatTabNav, { static: true }) public matTabNav: MatTabNav;
      public ngOnInit() {
        this.matTabNav._checkPaginationEnabled = _checkPaginationEnabled;
      }
    }
    
    function _checkPaginationEnabled() {
      {
        const isEnabled = this._tabList.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth + 1;
        if (!isEnabled) {
          this.scrollDistance = 0;
        }
        if (isEnabled !== this._showPaginationControls) {
          this._changeDetectorRef.markForCheck();
        }
        this._showPaginationControls = isEnabled;
      }
    }
    
    
  2. Anderman commented on Oct 23, 2019

    @Anderman
    Author

    related to #8907

  3. Anderman commented on Nov 28, 2019

    @Anderman
    Author

    @andrewseguin Another cause of wrong pagination is the inkt-bar. If the inkt-bar is outside the navigationbar the scrollwidth of the tablist give the wrong information.
    this should be this._tabList.nativeElement.firstChild.scrollWidth

    To fix this I update the patched function to:

    function _checkPaginationEnabled() {
    this._elementRef.nativeElement.offsetWidth, 'isEnabled', this._showPaginationControls);
      const isEnabled = this._tabList.nativeElement.firstChild.scrollWidth > this._elementRef.nativeElement.offsetWidth + 1;
      if (!isEnabled) { this.scrollDistance = 0; }
      if (isEnabled !== this._showPaginationControls) { this._changeDetectorRef.markForCheck(); }
      this._showPaginationControls = isEnabled;
    }
    
  4. added
    needs triage
    on May 20, 2020
  5. added
    cannot reproduce
    and removed
    needs triage
    on May 26, 2020
  6. jelbourn commented on May 26, 2020

    @jelbourn
    Contributor

    I wasn't able to reproduce this; feel free to open a new issue if you're able to provide a reproduction in StackBlitz

  7. angular-automatic-lock-bot commented on Jun 26, 2020

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: material/tabscannot reproduce

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions