primeng icon indicating copy to clipboard operation
primeng copied to clipboard

p-inputSwitch placed in sticky headers table is being shown on top of header while scrolling

Open zozo8 opened this issue 4 years ago • 2 comments

Describe the bug

p-inputSwitch placed in sticky headers table is being shown on top of header while scrolling, what makes strange, visual effect. Please see stackblitz attached: https://stackblitz.com/edit/primeng-tablesticky-demo-ahfuna?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts

image

Environment

Google Chrome 104.0.5112.81 Windows 11

Reproducer

https://stackblitz.com/edit/primeng-tablesticky-demo-ahfuna?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts

Angular version

11.0.4

PrimeNG version

13.0.4

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

0.0.0.

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

Switches should be hidden under the header as other controls

zozo8 avatar Aug 17 '22 05:08 zozo8

The problem occurs when not having a set z-index property that specifies the stack order of elements. However, adding z-index: 1; to your styles will make it work.

styles: [
    `
        :host ::ng-deep .p-datatable .p-datatable-thead > tr > th {
            position: -webkit-sticky;
            position: sticky;
            top: 0px;
            z-index: 1;
        }

        @media screen and (max-width: 64em) {
            :host ::ng-deep .p-datatable .p-datatable-thead > tr > th {
                top: 0px;
            }
        }
  `,
  ],

This is probably something that should be added to the "Sticky Table" documentation.

pistage avatar Aug 17 '22 10:08 pistage

Thank you, it solves the issue!

zozo8 avatar Aug 17 '22 10:08 zozo8