components icon indicating copy to clipboard operation
components copied to clipboard

Sticky columns show scrolled data between them.

Open stevencraigadesa opened this issue 7 years ago • 12 comments

What is the expected behavior?

Sticky columns should not show scrolled data between them.

What is the current behavior?

When making multiple columns sticky and resize the screen, Scrolled data can display between the sticky columns.

What are the steps to reproduce?

Used the stackblitz sticky column example. https://stackblitz.com/edit/angular-ay2dr9?file=app%2Ftable-sticky-columns-example.html

Made the first 3 columns sticky and the fourth column started to display between column 2 and 3.

image

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Is there anything else we should know?

stevencraigadesa avatar Apr 23 '19 17:04 stevencraigadesa

Here is with the scroll and symbol displays part before column 2 and part after column 2 image

stevencraigadesa avatar Apr 23 '19 17:04 stevencraigadesa

@andrewseguin is this maybe just missing a background color?

jelbourn avatar Apr 24 '19 15:04 jelbourn

I've seen the same problem after resize in my application. Not at all times, but often. It's not a missing background color, the css left property for the sticky column is not always updated respectively to early with old values.

My workaround for now is calling in the resize event handler this.ngZone.onMicrotaskEmpty.pipe(take(3)).subscribe(() => this.table.updateStickyColumnStyles()); but of course it would be nice to avoid this.

PS: take(3) is to make sure the actual styles will be applied. take(1) isn't sufficient.

lpl14 avatar Apr 24 '19 21:04 lpl14

Any word on this?

robertsmith2 avatar May 17 '19 20:05 robertsmith2

Same issue on Chrome 79. Apply a style on table element:

style="border-collapse: separate"

Ref: https://stackoverflow.com/a/53559396/3378679

romaincausse avatar Jan 23 '20 16:01 romaincausse

Having the same issue... any update?

Caitlin-Finn avatar Apr 01 '20 18:04 Caitlin-Finn

Same issue when I have a long text in a column, below the first column is sticky and have a long text in the first cell.

image

For now working with below work around.

  @ViewChild('matTable', { static: false }) set table(matTable: MatTable<any>) {
    if (matTable) {
      this.ngZone.onMicrotaskEmpty
        .pipe(take(3))
        .subscribe(() => matTable.updateStickyColumnStyles())
    }
  }

renjithpn avatar Jul 15 '20 16:07 renjithpn

I have the same issue, it only seems to happen if I have 3 or more sticky columns. image

nienow avatar Sep 01 '20 00:09 nienow

Had the same issue

None of the above proposed solutions worked for me However this worked :

@ViewChild(MatTable) table: MatTable<any>;

ngAfterViewChecked(): void {
    if (this.table) {
        this.table.updateStickyColumnStyles();
    }
}

lancelot-c avatar Oct 15 '20 18:10 lancelot-c

This works for me. It enables that only for the tables with the sticky columns:

 @ContentChild(MatTable, { static: false }) set table(val: MatTable<any>) {
    this.ngZone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => {
      if (val?._contentColumnDefs?.some((x) => x.sticky || x.stickyEnd)) {
        val.updateStickyColumnStyles();
      }
    });
  }

ysdidenko avatar Aug 09 '21 14:08 ysdidenko

@lancelot-c 's solution worked for me :+1:

webcat12345 avatar Aug 05 '22 03:08 webcat12345

The provided solutions didn't work for me - especially for a dialog. I applied the following style from #23954

position: sticky;
z-index: 10;

I have as well problems with the overflow especially with two rows in the header but I think my problem is basically one the these two tickets.

leomayer avatar Nov 11 '22 10:11 leomayer