Skip to content

bug(MatTabHeader): Rouding problem when zooming will show PaginationControls when not needed #23724

Closed

Description

@Anderman

Reproduction

Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/angular-1v9muy
see also issue mat-tab-header-pagination displaying incorrectl

Steps to reproduce:

  1. open in fullscreen and try to zoom in and out until there are PaginationControls visible

Expected Behavior

No PaginationControls when not needed

Actual Behavior

PaginationControls are visible. Sometimes they are always but are not easy to reproduce in stackblitz

Environment

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

Can be fixed by adding 1
see also SO

// original code from paginated-tab-header

function _checkPaginationEnabled(this: MatTabHeader) {
  if (this.disablePagination) {
    this._showPaginationControls = false;
  } else {
    // const isEnabled = this._tabList.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth;
    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;
  }
}

Log of scrollwidth,offsetwidth when zooming in and out. The scrollwidth is not constant with a specefic zooming level but offset width is.
image

Activity

  1. added
    needs triage
    on Oct 10, 2021
  2. jelbourn commented on Oct 14, 2021

    @jelbourn
    Contributor

    @Anderman at which zoom level do you run into this?

  3. added a commit that references this issue on Oct 15, 2021
    a8dd126
  4. crisbeto commented on Oct 15, 2021

    @crisbeto
    Member

    I don't think that the problem is a rounding error, but rather than the ink bar has a transition and it ends up overflowing the container while it is being measured. I've submitted #23759 that should resolve it.

  5. self-assigned this
    on Oct 15, 2021
  6. added
    P3
    and removed
    needs triage
    on Oct 15, 2021
  7. added a commit that references this issue on Oct 25, 2021
    989ece8
  8. added 2 commits that reference this issue on Nov 15, 2021
    8cdd3d7
    759d85a
  9. angular-automatic-lock-bot commented on Dec 16, 2021

    @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.

  10. locked and limited conversation to collaborators on Dec 16, 2021
  11. added a commit that references this issue on Apr 3, 2022
    c11d706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3area: material/tabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions