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 header groups overlap each other #42165

Open
ThisIsHG opened this issue May 8, 2024 · 3 comments
Open

Sticky header groups overlap each other #42165

ThisIsHG opened this issue May 8, 2024 · 3 comments
Assignees
Labels
component: table This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@ThisIsHG
Copy link

ThisIsHG commented May 8, 2024

Steps to reproduce

Just scroll down in the sample and the second header will overlap the firs.

Sample here

Current behavior

Both headers stick to the upper container edge and overlap each other

Expected behavior

The group as a whole should stick to the top and not each individual header so they wont overlap.

I did some testing and noticed that each TableRow in the header sticks to top: 0 and the TableHead scrolls away. My expectation would be that the hole Group sticks to the top instead of each individual row. I also did some testing in the devtools and it looked like adding top: 0 to the TableHead would solve the problem.

Looking forward to hear back from you guys! :)

Context

I'm currently working on a larger table with sticky header groups. Where the Bottom one will overlap the top one so the information displayed is not visible.

Your environment

System:
OS: Windows 10 10.0.19045
Binaries:
Node: 20.11.1 - ~\scoop\apps\nodejs-lts\current\node.EXE
npm: 10.2.4 - ~\scoop\apps\nodejs-lts\current\npm.CMD
pnpm: 8.15.4 - ~\scoop\apps\nodejs-lts\current\bin\pnpm.CMD
Browsers:
Chrome: 124.0.6367.119
Edge: Chromium (123.0.2420.97)

Search keywords: Sticky header groups overlapping

@ThisIsHG ThisIsHG added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 8, 2024
@zannager zannager added the component: table This is the name of the generic UI component, not the React module! label May 8, 2024
@brijeshb42 brijeshb42 added the package: material-ui Specific to @mui/material label May 10, 2024
@brijeshb42
Copy link
Contributor

Can you update the example to show what you want to achieve after applying the fix? Maybe there is already a way to get that.

@brijeshb42 brijeshb42 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 10, 2024
@ThisIsHG
Copy link
Author

Sample is updated to show what i would expect.

Basicly I would expect to still be able to see both headers after scrolling.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 10, 2024
@yassinmars
Copy link

it appears that the issue arises because both header rows are using position: sticky with the same top: 0 value, causing them to overlap when scrolling. To fix this maybe we can adjust the top values for each header row to ensure they stack properly without overlapping. Here's a CSS suggestion:

TableHead {
.MuiTableCell-root {
position: sticky;
top: 0; // Keep this for the first header row
z-index: 10; // Ensures this row stays on top when scrolling
}

.MuiTableRow-root:first-of-type .MuiTableCell-root {
top: 0; // First header row
}

.MuiTableRow-root:last-of-type .MuiTableCell-root {
top: 56px; // Adjust this value based on the actual height of your first header row
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

5 participants