Skip to content

bug(tabs): scroll position not reset when tabs are removed #24117

Closed

Description

@ajafff

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

probably never worked

Description

The scroll position of a mat-tab-nav-bar is not clamped to the max scroll distance when tabs are removed, but is still scrollable.

Reproduction

Steps to reproduce:

  1. Open Stackblitz: https://stackblitz.com/edit/components-issue-s5jn1k?file=src/app/example-component.ts
  2. Scroll all the way to the end of the tab nav
  3. Click on the button to remove the first 2 tabs
  4. Tabs scroll out of view, because scroll position is not reset to _getMaxScrollDistance

Related: Clicking on the button again to remove another 2 tabs scrolls the content back into view, because now the nav bar is no longer scrollable (this was fixed by #23759)

Expected Behavior

Scroll position is never greater than maximum scroll distance

Actual Behavior

Scroll position remains the same, tabs are scrolled out of view

Environment

  • Angular: 13.1.1
  • CDK/Material: 13.1.1
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

Activity

  1. added
    needs triage
    on Dec 17, 2021
  2. self-assigned this
    on Dec 18, 2021
  3. added
    P3
    and removed
    needs triage
    on Dec 18, 2021
  4. added a commit that references this issue on Dec 18, 2021
    aa44e82
  5. added 2 commits that reference this issue on Mar 31, 2022
    b83d225
    0a4fdb2
  6. added a commit that references this issue on Apr 3, 2022
    5b8b228
  7. angular-automatic-lock-bot commented on May 1, 2022

    @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 May 1, 2022
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