angular / angular/components

bug(TABLE): 'sticky' directive positions column in wrong place when using more than one 'mat-header-row' on the table

Open
#22,023 4 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: material/table P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

Description

It is known that you can set sticky directive for more than one matColumnDef. It is also known that you can have more than one row of table heading (mat-header-row). However, with more than one mat-header-row the sticky feature breaks the table layout.

Reproduction

https://stackblitz.com/edit/cdk-table-multi-row-heading-sticky-column

Steps to reproduce:

  1. Open the stackblitz, play a bit with sticky directive after reading expected and actual behavior.
Expected Behavior
  1. Both columns are sticky - 1st and 2nd and in proper place
  2. If sticky is applied to column with colspan, I expect both 'spanned' columns below it should be sticky
Actual Behavior

What behavior did you actually see?

  1. 1st and 2nd columns are sticky, but 2nd column is missplaced (has moved to the right), covering another column named item.
    image

  2. If you add sticky to the 'grouping' header no. it only makes group header cell to be sticky - not the whole 2 collumns with 1st and 2nd values.

Environment
  • Angular: 11.2.3
  • CDK/Material: 11.2.2
  • Browser(s): Chrome Version 88.0.4324.182 (Official Build) (64-bit)
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by opening the linked StackBlitz reproduction and inspect src/app/app.component.html, focusing on the multiple mat-header-row elements and sticky directives. Reproduce both reported cases, then trace the Angular CDK/Material table sticky behavior. Done means sticky columns remain in the correct position and a sticky colspan header keeps its spanned columns sticky.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.