-
-
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
[DataGrid] Fix GridOverlays
bypassing pointer events
#5674
Conversation
These are the results for the performance tests:
|
@cherniavskii I'm not sure what to suggest then, the change to add |
What we can do to solve both issues is to:
This diff should do the job: diff --git a/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx b/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
index 8e7e4ea35..55ef3921f 100644
--- a/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
+++ b/packages/grid/x-data-grid/src/components/GridLoadingOverlay.tsx
@@ -1,14 +1,23 @@
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 (
- <GridOverlay ref={ref} {...props}>
+ <GridLoadingOverlayRoot ref={ref} {...props}>
<CircularProgress />
- </GridOverlay>
+ </GridLoadingOverlayRoot>
);
},
);
diff --git a/packages/grid/x-data-grid/src/components/base/GridOverlays.tsx b/packages/grid/x-data-grid/src/components/base/GridOverlays.tsx
index c4f1fec86..ce3a618e5 100644
--- a/packages/grid/x-data-grid/src/components/base/GridOverlays.tsx
+++ b/packages/grid/x-data-grid/src/components/base/GridOverlays.tsx
@@ -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
- pointerEvents: 'none',
}}
{...props}
/> |
GridOverlays
bypassing pointer events
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
@cherniavskii shouldn't we keep zIndex: 4
here? It was added in #4863. Without it, other overlays, e.g. no filter results, don't take the full height.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
How can we test this locally?
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
@m4theushw nice catch!
I think we should not keep zIndex on the overlay wrapper, because there's no way to customize it.
Instead, we can move those styles to GridOverlay
instead:
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).
But most importantly, it would allow to implement custom overlays with interactive elements while avoiding pointerEvents: none
(so it won't cause another issue like #5590).
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
@philjones88
Thanks! Can you rebase again to restart the CI? The failure in Argos CI looks like a false negative
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.
@cherniavskii I pushed an empty commit to trigger the CI. The branch was already up to date with master. Seems to have all passed!
1cdf936
to
15346e2
Compare
@@ -44,8 +44,6 @@ function GridOverlayWrapper(props: React.PropsWithChildren<{}>) { | |||
position: 'absolute', |
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 add zIndex
#5674 (comment), the overlay stays behind the virtual scroller because it has position: relative
, while the overlay has position: absoulte
. We need to put the overlay on top of everything to fix #5725 too
position: 'absolute', | |
position: 'relative', |
In 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
the overlay stays behind the virtual scroller because it has position: relative, while the overlay has position: absoulte
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:
const NoRowsOverlay = () => {
return <div style={{ position: 'relative', zIndex: 1 }}></div>
}
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
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.
Looks good. It's what we can do given the constraints we have. In v6 we can rearrange the overlay to render correctly without additional styling.
Thanks @philjones88 |
Fixes #5590