Skip to content

Commit

Permalink
fix: quickfilter outside of root
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk committed Jan 9, 2025
1 parent 049a999 commit a9c8b65
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import * as React from 'react';
import Portal from '@mui/material/Portal';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import { DataGrid, GridToolbarQuickFilter, GridToolbar } from '@mui/x-data-grid';
import {
DataGrid,
GridPortalWrapper,
GridToolbarQuickFilter,
GridToolbar,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function MyCustomToolbar(props) {
return (
<React.Fragment>
<Portal container={() => document.getElementById('filter-panel')}>
<GridToolbarQuickFilter />
<GridPortalWrapper>
<GridToolbarQuickFilter />
</GridPortalWrapper>
</Portal>
<GridToolbar {...props} />
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import * as React from 'react';
import Portal from '@mui/material/Portal';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import { DataGrid, GridToolbarQuickFilter, GridToolbar } from '@mui/x-data-grid';
import {
DataGrid,
GridPortalWrapper,
GridToolbarQuickFilter,
GridToolbar,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function MyCustomToolbar(props: any) {
return (
<React.Fragment>
<Portal container={() => document.getElementById('filter-panel')!}>
<GridToolbarQuickFilter />
<GridPortalWrapper>
<GridToolbarQuickFilter />
</GridPortalWrapper>
</Portal>
<GridToolbar {...props} />
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Below are described the steps you need to make to migrate from v7 to v8.
### Other exports

- `ariaV8` experimental flag is removed. It's now the default behavior.
- Sub-components that are in a React Portal must now be wrapped with `GridPortalWrapper`

Check failure on line 101 in docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.CorrectReferenceAllCases] Use 'subcomponents' instead of 'Sub-components' Raw Output: {"message": "[MUI.CorrectReferenceAllCases] Use 'subcomponents' instead of 'Sub-components'", "location": {"path": "docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md", "range": {"start": {"line": 101, "column": 3}}}, "severity": "ERROR"}

<!-- ### Editing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export function useThemeVariablesClassName() {
return getClassNameForTheme(useTheme());
}

export function GridPortalWrapper({ children }: { children: React.ReactNode }) {
const className = useThemeVariablesClassName();
return <div className={className}>{children}</div>;
}

function getClassNameForTheme(theme: Theme) {
let className = classNameByTheme.get(theme);
if (className) {
Expand Down
1 change: 1 addition & 0 deletions packages/x-data-grid/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export type { OutputSelector } from './createSelector';
export { GridPortalWrapper } from './css/themeManager';
1 change: 1 addition & 0 deletions scripts/x-data-grid-premium.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
{ "name": "GridPinnedRowNode", "kind": "TypeAlias" },
{ "name": "GridPinnedRowsProp", "kind": "Interface" },
{ "name": "GridPipeProcessingLookup", "kind": "Interface" },
{ "name": "GridPortalWrapper", "kind": "Function" },
{ "name": "GridPreferencePanelInitialState", "kind": "TypeAlias" },
{ "name": "GridPreferencePanelParams", "kind": "Interface" },
{ "name": "GridPreferencePanelState", "kind": "Interface" },
Expand Down
1 change: 1 addition & 0 deletions scripts/x-data-grid-pro.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
{ "name": "GridPinnedRowNode", "kind": "TypeAlias" },
{ "name": "GridPinnedRowsProp", "kind": "Interface" },
{ "name": "GridPipeProcessingLookup", "kind": "Interface" },
{ "name": "GridPortalWrapper", "kind": "Function" },
{ "name": "GridPreferencePanelInitialState", "kind": "TypeAlias" },
{ "name": "GridPreferencePanelParams", "kind": "Interface" },
{ "name": "GridPreferencePanelState", "kind": "Interface" },
Expand Down
1 change: 1 addition & 0 deletions scripts/x-data-grid.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
{ "name": "gridPinnedColumnsSelector", "kind": "Variable" },
{ "name": "GridPinnedRowNode", "kind": "TypeAlias" },
{ "name": "GridPipeProcessingLookup", "kind": "Interface" },
{ "name": "GridPortalWrapper", "kind": "Function" },
{ "name": "GridPreferencePanelInitialState", "kind": "TypeAlias" },
{ "name": "GridPreferencePanelParams", "kind": "Interface" },
{ "name": "GridPreferencePanelState", "kind": "Interface" },
Expand Down

0 comments on commit a9c8b65

Please sign in to comment.