Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky headers fails to work with multiple headers. #130

Open
sagar2610 opened this issue Mar 11, 2024 · 1 comment · May be fixed by #133
Open

Sticky headers fails to work with multiple headers. #130

sagar2610 opened this issue Mar 11, 2024 · 1 comment · May be fixed by #133

Comments

@sagar2610
Copy link

My mat-table has 3 header rows. The first one is sticky: false and the other two are sticky: true, the sticky header keep scrolling with the content.

@msabljak
Copy link

msabljak commented Nov 22, 2024

I dont know if you still need it but I made a local hotfix for this broken behaviour

you can apply the same for the setStickyFooter

private setStickyHeader(offset: number) {
    let stickyOffset = offset;
    this.scrollStrategy.viewport.elementRef.nativeElement
      .querySelectorAll(stickyHeaderSelector)
      .forEach((el: Element) => {
        const parent = el.parentElement;
        if (!parent) return;
        let baseOffset = 0;
        if (this.stickyPositions?.has(parent)) {
          baseOffset = this.stickyPositions.get(parent)!;
        }
        el.setAttribute('style', `${el.getAttribute('style')} top: ${baseOffset + offset + stickyOffset}px`);
        stickyOffset+= el.getBoundingClientRect().height;
      });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants