angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.32k stars 6.73k forks source link

bug(mat-expansion-panel): header position is incorrect when call elementInsideMatExpansionPanel.scrollIntoView(true) #21159

Open stargazer8tw opened 3 years ago

stargazer8tw commented 3 years ago

Reproduction

Steps to reproduce:

  1. open StackBlitz reproduce example
  2. scroll to bottom
  3. click Test ScrollIntoView button.

or.

  1. Add <span class="target">test</span> inside mat-expansion-panel tag.
  2. Set mat-expansion-panel expanded="false".
  3. Call elementInsideMatExpansionPanel.scrollIntoView(true), e.g. document.querySelector('.bug-target').scrollIntoView(true).

Expected Behavior

Viewport scrolls to mat-expansion-panel with mat-expansion-panel-header display, and element inside mat-expansion-panel remains hidden.

Actual Behavior

Viewport scrolls to mat-expansion-panel and causes mat-expansion-panel-header x-position changed and mat-expansion-panel-header is not display.

Environment

Workaround

Call window.scroll or scrollTo function, see StackBlitz reproduce example

crisbeto commented 3 years ago

Double-checking that I understood the issue correctly: the problem you're reporting is that the header text disappears when pressing the Test ScrollIntoView, correct?

stargazer8tw commented 3 years ago

Yes, that's correct. The header text disappears when pressing the Test ScrollIntoView.

crisbeto commented 3 years ago

Better repro from #21622: https://stackblitz.com/edit/angular-yg9mb5.

jazpearson commented 1 year ago

We've just run into this ourselves....

skantemneni commented 1 year ago

I ran into this same issue on latest version of Angular Material...."@angular/material": "^16.1.3". Hope there is an answer. I defaulted to scrolling to just the Expansion Panel as a while. Not any particular element within.

WaveBeat commented 10 months ago

Would be nice to get a fix for this