Skip to content

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

Closed
@ajafff

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/tabs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions