Skip to content

Commit

Permalink
[DataGrid] Allow to pass props to the TrapFocus inside the panel wr…
Browse files Browse the repository at this point in the history
…apper (#7733)

Co-authored-by: Matheus Wichman <matheushw@outlook.com>
  • Loading branch information
Vivek-Prajapatii and m4theushw committed Feb 10, 2023
1 parent 784ead8 commit 44fc97b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ GridColumnsPanel.propTypes = {
// ----------------------------------------------------------------------
autoFocusSearchField: PropTypes.bool,
searchPredicate: PropTypes.func,
slotProps: PropTypes.object,
sort: PropTypes.oneOf(['asc', 'desc']),
} as any;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
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/material';
Expand Down Expand Up @@ -37,17 +38,21 @@ const isEnabled = () => true;

export interface GridPanelWrapperProps
extends React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>,
MUIStyledCommonProps<Theme> {}
MUIStyledCommonProps<Theme> {
slotProps?: {
TrapFocus?: TrapFocusProps;
};
}

const GridPanelWrapper = React.forwardRef<HTMLDivElement, GridPanelWrapperProps>(
function GridPanelWrapper(props, ref) {
const { className, ...other } = props;
const { className, slotProps = {}, ...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} {...slotProps.TrapFocus}>
<GridPanelWrapperRoot
ref={ref}
tabIndex={-1}
Expand All @@ -59,4 +64,12 @@ const GridPanelWrapper = React.forwardRef<HTMLDivElement, GridPanelWrapperProps>
},
);

GridPanelWrapper.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
slotProps: PropTypes.object,
} as any;

export { GridPanelWrapper };

0 comments on commit 44fc97b

Please sign in to comment.