-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DataGrid] Fix GridOverlays
bypassing pointer events
#5674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,6 @@ function GridOverlayWrapper(props: React.PropsWithChildren<{}>) { | |
position: 'absolute', | ||
top: headerHeight, | ||
bottom: height === 'auto' ? 0 : undefined, | ||
zIndex: 4, // should be above pinned columns, pinned rows and detail panel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cherniavskii shouldn't we keep I added a background on purpose to one overlay. Here it's how it looks like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could add it back, I thought moving it in the git patch proposed would be ok but the naming suggests that zIndex only applies to loading overlays... How can we test this locally? Is thee a way to produce a custom NPM package? do a file:/ reference in my project's package.json... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@philjones88 Please refer to the contribution guide for options on how to test an unreleased package. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @m4theushw nice catch! Instead, we can move those styles to diff --git a/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx b/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
index 55ef3921f..8e7e4ea35 100644
--- a/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
+++ b/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
@@ -1,23 +1,14 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import CircularProgress from '@mui/material/CircularProgress';
-import { styled } from '@mui/material/styles';
import { GridOverlay, GridOverlayProps } from './containers/GridOverlay';
-const GridLoadingOverlayRoot = styled(GridOverlay)({
- position: 'absolute',
- top: 0,
- zIndex: 4, // should be above pinned columns, pinned rows and detail panel
- width: '100%',
- pointerEvents: 'none',
-});
-
const GridLoadingOverlay = React.forwardRef<HTMLDivElement, GridOverlayProps>(
function GridLoadingOverlay(props, ref) {
return (
- <GridLoadingOverlayRoot ref={ref} {...props}>
+ <GridOverlay ref={ref} {...props}>
<CircularProgress />
- </GridLoadingOverlayRoot>
+ </GridOverlay>
);
},
);
diff --git a/packages/grid/x-data-grid/src/components/containers/GridOverlay.tsx b/packages/grid/x-data-grid/src/components/containers/GridOverlay.tsx
index 789704435..77146b237 100644
--- a/packages/grid/x-data-grid/src/components/containers/GridOverlay.tsx
+++ b/packages/grid/x-data-grid/src/components/containers/GridOverlay.tsx
@@ -29,8 +29,13 @@ const GridOverlayRoot = styled('div', {
slot: 'Overlay',
overridesResolver: (props, styles) => styles.overlay,
})(({ theme }) => ({
- display: 'flex',
+ position: 'absolute',
+ top: 0,
+ zIndex: 4, // should be above pinned columns, pinned rows and detail panel
+ width: '100%',
height: '100%',
+ pointerEvents: 'none',
+ display: 'flex',
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'center', This would make default overlays taking full height while allowing to scroll horizontally (for example to access column used for filtering that is not in the viewport). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried to push the proposed changes to this branch to make sure there's no visual regressions, but turned out I don't have the permission to push to https://github.com/VQComms/mui-x/tree/remove-grid-overlays-pointer-events-style @philjones88 could you push the changes so we trigger the CI? Merging latest master to this branch would be good as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've applied the git diff above, updated my fork and rebased this branch onto master latest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @philjones88 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cherniavskii I pushed an empty commit to trigger the CI. The branch was already up to date with master. Seems to have all passed! |
||
pointerEvents: 'none', | ||
}} | ||
{...props} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed
pointerEvents: none
but this was not sufficient to fix #5725. Since we didn't addzIndex
#5674 (comment), the overlay stays behind the virtual scroller because it hasposition: relative
, while the overlay hasposition: absoulte
. We need to put the overlay on top of everything to fix #5725 tooIn https://codesandbox.io/s/mui-x-norowsoverlay-bug-forked-g6npfv?file=/src/App.tsx I still can't click the button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR only fixes the regression described in #5590
#5725 is a bit different, since it was reproducible in v5.13.0 as well (before #5590 regression introduced in 5.14.0) - see https://codesandbox.io/s/mui-x-norowsoverlay-bug-forked-tzjfhj?file=/src/App.tsx
We tried to fix it with #5558, but this introduced the regression above.
If we add zIndex to
GridOverlays
- then https://github.com/mui/mui-x/blob/master/test/e2e/index.test.ts#L330 would fail.This is the reason I've added
pointerEvents: 'none'
, so that scroll gets bypassed to virtualScroller.So it's kind of a vicious circle with the regressions here :D
For the #5725, after we merge this PR users can do this for custom overlays:
That's the best trade-off I see right now, but I'm open to other solutions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One solution that would keep https://github.com/mui/mui-x/blob/master/test/e2e/index.test.ts#L330 passing is to render the overlays inside the virtualization component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it will be possible to do without breaking changes - I'll take a look