-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] The filter panel in custom toolbar steal the focus from an input #7044
Comments
The filter panel is based on the If this is acceptable, then we need to give the possibility of passing props to the diff --git a/packages/grid/x-data-grid/src/components/panel/GridPanelWrapper.tsx b/packages/grid/x-data-grid/src/components/panel/GridPanelWrapper.tsx
index f738196ce..4701aa1bf 100644
--- a/packages/grid/x-data-grid/src/components/panel/GridPanelWrapper.tsx
+++ b/packages/grid/x-data-grid/src/components/panel/GridPanelWrapper.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
-import TrapFocus from '@mui/material/Unstable_TrapFocus';
+import TrapFocus, { TrapFocusProps } from '@mui/material/Unstable_TrapFocus';
import { styled, Theme } from '@mui/material/styles';
import { MUIStyledCommonProps } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
@@ -36,18 +36,20 @@ const GridPanelWrapperRoot = styled('div', {
const isEnabled = () => true;
export interface GridPanelWrapperProps
- extends React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>,
+ extends React.PropsWithChildren<
+ React.HTMLAttributes<HTMLDivElement> & { TrapFocusProps: Omit<TrapFocusProps, 'open'> }
+ >,
MUIStyledCommonProps<Theme> {}
const GridPanelWrapper = React.forwardRef<HTMLDivElement, GridPanelWrapperProps>(
function GridPanelWrapper(props, ref) {
- const { className, ...other } = props;
+ const { className, TrapFocusProps: TrapFocusPropsProps, ...other } = props;
const rootProps = useGridRootProps();
const ownerState = { classes: rootProps.classes };
const classes = useUtilityClasses(ownerState);
return (
- <TrapFocus open disableEnforceFocus isEnabled={isEnabled}>
+ <TrapFocus open disableEnforceFocus isEnabled={isEnabled} {...TrapFocusPropsProps}>
<GridPanelWrapperRoot
ref={ref}
tabIndex={-1} Then, <DataGrid
componentsProps={{ filterPanel: { TrapFocusProps: { disableRestoreFocus: true } } }}
/> Do you want to submit a PR with the diff above? |
This comment was marked as outdated.
This comment was marked as outdated.
@Vivek-Prajapatii Yes, you can find more information in https://github.com/mui/material-ui/blob/HEAD/CONTRIBUTING.md. When opening the PR make sure to set the target branch to |
@m4theushw @Vivek-Prajapatii @sasa5195 Is this solution is available in the MUI or still needs to be updated ? Do we have a workaround solution to fix this? |
This comment was marked as outdated.
This comment was marked as outdated.
I have simplified the problem a bit more in https://codesandbox.io/s/date-range-picker-issue-in-data-grid-inside-cutom-toolbar-forked-smx7j4?file=/demo.js so that we can consider the issue without the date pickers, a basic Screen.Recording.2023-01-28.at.20.00.16.movOverall, I think that it's more a
I have noticed the same bug on this demo: https://mui.com/material-ui/react-menu/#menulist-composition, 2. could be its solution) |
@oliviertassinari I also agree but we can't wait for the Core to properly fix this bug (if there's a proper fix available). My proposal here is to at least allow a workaround.
I've proposed a more customizable solution in mui/material-ui#35307 |
#7733 is merged and it will be included in the next release. For now, the following workaround can be used: <DataGrid
componentsProps={{
filterPanel: {
slotProps: {
TrapFocus: {
disableRestoreFocus: true,
},
},
},
}}
/> |
@m4theushw I'm reopening as the UX is broken by default; It's great that we have a workaround 👍 |
@m4theushw @oliviertassinari On which version we can use this workaround I have tried 5.17.23 and even 6.0.0-beta.3 #7696 issue is still happening Codesandbox |
@ayushcs It will be available in the version we're going to release this week, probably on Thursday. |
Hey @cherniavskii, we had another report of this issue: mui/material-ui#45150. The workaround suggested in #7044 (comment) works as well, although it throws a typescript error as I'll close the duplicate issue in favor of this one so the discussion can continue here. |
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/tender-shannon-2o3hv7
https://www.loom.com/share/eb4bd147cdb043139c30a055f0f9f842
Browser - Chrome, Firefox
Steps:
Steps:
Current behavior 😯
Opening the date range picker after the filter panel or column panel closes the date range picker automatically for the first time.
But this doesn't happens when density menu appears and date range picker is being opened
Expected behavior 🤔
Opening the date range picker after the filter panel or column panel should not close the date range picker automatically. It should behave the same way as when we toggle between different panels like filter, column, density, etc.
Context 🔦
I need to add a date range filter which is not related to the columns of the data grid. So inorder to achieve that i am using the date range picker component and placing it in the data grid toolbar.
Your environment 🌎
npx @mui/envinfo
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: