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

[Table] Sticky header table with buttons/inputs #17276

Closed
2 tasks done
Studio384 opened this issue Sep 2, 2019 · 10 comments · Fixed by #17285 or #17968
Closed
2 tasks done

[Table] Sticky header table with buttons/inputs #17276

Studio384 opened this issue Sep 2, 2019 · 10 comments · Fixed by #17285 or #17968
Labels
bug 🐛 Something doesn't work component: table This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@Studio384
Copy link
Contributor

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

https://codesandbox.io/s/create-react-app-6v20t

Buttons and input are visible on top of the sticky header.

Expected Behavior 🤔

The buttons and input go below the sticky header.

Steps to Reproduce 🕹

Use a button or input field (I haven't checked anything else) in a table with sticky headers.

Context 🔦

I'm trying to make a table which has options within its rows.

Your Environment 🌎

Tech Version
Material-UI v4.4.0
React v16.9.0
Browser Any
@oliviertassinari oliviertassinari added component: table This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. labels Sep 2, 2019
@oliviertassinari
Copy link
Member

@Studio384 Thanks for the report. It seems that the fix is simple, creating a stacking context address it:

diff --git a/packages/material-ui/src/TableCell/TableCell.js b/packages/material-ui/src/TableCell/TableCell.js
index a81b2417e..a034c45fe 100644
--- a/packages/material-ui/src/TableCell/TableCell.js
+++ b/packages/material-ui/src/TableCell/TableCell.js
@@ -101,6 +101,7 @@ export const styles = theme => ({
     position: 'sticky',
     top: 0,
     left: 0,
+    zIndex: 1,
     backgroundColor: theme.palette.background.default,
   },
 });

@Ramkumar92
Copy link

Ramkumar92 commented Sep 2, 2019

Thanks, Super easy fix, was obvious but didn't try until seeing this,
Why does this occur only on certain components and not on other components like Typography?

@oliviertassinari
Copy link
Member

To be honest, I don't know why it happens with such component. Maybe we already create a stacking context for them?

@oliviertassinari
Copy link
Member

Does anyone want to submit a pull request for the problem? :)

@LavaToaster
Copy link
Contributor

I can open a new issue for this, but I figure this is basically the same issue. Buttons work, but the checkboxes are still affected.

See: https://codesandbox.io/s/create-react-app-4stgk

@oliviertassinari
Copy link
Member

@Lavoaster I can't reproduce it. What environment are you using? Do you have a screenshot,

@LavaToaster
Copy link
Contributor

@oliviertassinari Sorry, I just realised that the issue is a little bit different.

In this case if you try to check the box in the header, whilst a checkbox is beneath it, it checks the the one beneath the sticky header.

I'm on mac OS 10.15, with Chrome77.0.3865.120, I also tested this in safari and the same issue occurs.

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 19, 2019

@Lavoaster I can reproduce it too. The z-index: 1 added in #17389 conflicts. What about increasing the z-index to 2 for the sticky header?

@LavaToaster
Copy link
Contributor

@oliviertassinari That makes it work for me.

@oliviertassinari
Copy link
Member

@Lavoaster Do you want to submit a pull request? Or do you have a better fix in mind? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: table This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
4 participants