https://codesandbox.io/s/create-react-app-6v20t
Buttons and input are visible on top of the sticky header.
The buttons and input go below the sticky header.
Use a button or input field (I haven't checked anything else) in a table with sticky headers.
I'm trying to make a table which has options within its rows.
| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.4.0 |
| React | v16.9.0 |
| Browser | Any |
@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,
},
});
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?
To be honest, I don't know why it happens with such component. Maybe we already create a stacking context for them?
Does anyone want to submit a pull request for the problem? :)
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.
@Lavoaster I can't reproduce it. What environment are you using? Do you have a screenshot,
@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.
@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?
@oliviertassinari That makes it work for me.
@Lavoaster Do you want to submit a pull request? Or do you have a better fix in mind? :)
Most helpful comment
@Studio384 Thanks for the report. It seems that the fix is simple, creating a stacking context address it: