Skip to content

Commit c60afb0

Browse files
heltHendrik Lücke-Tieke
andauthored
Fixed theme index in fullscreen mode (#1048)
Co-authored-by: Hendrik Lücke-Tieke <[email protected]>
1 parent 4eade9d commit c60afb0

File tree

2 files changed

+126
-1
lines changed

2 files changed

+126
-1
lines changed

packages/material-react-table/src/components/table/MRT_TablePaper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Paper, { type PaperProps } from '@mui/material/Paper';
2+
import { useTheme } from '@mui/material'
23
import { MRT_TableContainer } from './MRT_TableContainer';
34
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
45
import { parseFromValuesOrFunc } from '../../utils/utils';
@@ -33,6 +34,8 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
3334
...rest,
3435
};
3536

37+
const theme = useTheme();
38+
3639
return (
3740
<Paper
3841
elevation={2}
@@ -58,7 +61,7 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
5861
right: 0,
5962
top: 0,
6063
width: '100dvw',
61-
zIndex: 999,
64+
zIndex: theme.zIndex.modal + 1,
6265
}
6366
: {}),
6467
...paperProps?.style,
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { AppBar, Box, CssBaseline, Toolbar } from '@mui/material';
2+
import { type Meta } from '@storybook/react';
3+
import { MaterialReactTable, useMaterialReactTable, type MRT_ColumnDef } from '../../src';
4+
5+
const meta: Meta = {
6+
title: 'Fixed Bugs/AppBar overlaps with Fullscreen Modal',
7+
};
8+
9+
export default meta;
10+
11+
12+
13+
//example data type
14+
type Person = {
15+
name: {
16+
firstName: string;
17+
lastName: string;
18+
};
19+
address: string;
20+
city: string;
21+
state: string;
22+
};
23+
24+
//nested data is ok, see accessorKeys in ColumnDef below
25+
const data: Person[] = [
26+
{
27+
name: {
28+
firstName: 'John',
29+
lastName: 'Doe',
30+
},
31+
address: '261 Erdman Ford',
32+
city: 'East Daphne',
33+
state: 'Kentucky',
34+
},
35+
{
36+
name: {
37+
firstName: 'Jane',
38+
lastName: 'Doe',
39+
},
40+
address: '769 Dominic Grove',
41+
city: 'Columbus',
42+
state: 'Ohio',
43+
},
44+
{
45+
name: {
46+
firstName: 'Joe',
47+
lastName: 'Doe',
48+
},
49+
address: '566 Brakus Inlet',
50+
city: 'South Linda',
51+
state: 'West Virginia',
52+
},
53+
{
54+
name: {
55+
firstName: 'Kevin',
56+
lastName: 'Vandy',
57+
},
58+
address: '722 Emie Stream',
59+
city: 'Lincoln',
60+
state: 'Nebraska',
61+
},
62+
{
63+
name: {
64+
firstName: 'Joshua',
65+
lastName: 'Rolluffs',
66+
},
67+
address: '32188 Larkin Turnpike',
68+
city: 'Omaha',
69+
state: 'Nebraska',
70+
},
71+
];
72+
73+
const columns: MRT_ColumnDef<Person>[] = [
74+
{
75+
accessorKey: 'name.firstName', //access nested data with dot notation
76+
header: 'First Name',
77+
size: 150,
78+
},
79+
{
80+
accessorKey: 'name.lastName',
81+
header: 'Last Name',
82+
size: 150,
83+
},
84+
{
85+
accessorKey: 'address', //normal accessorKey
86+
header: 'Address',
87+
size: 200,
88+
},
89+
{
90+
accessorKey: 'city',
91+
header: 'City',
92+
size: 150,
93+
},
94+
{
95+
accessorKey: 'state',
96+
header: 'State',
97+
size: 150,
98+
},
99+
];
100+
101+
102+
export const FullscreenIsAboveAppbar = () => {
103+
104+
105+
const table = useMaterialReactTable({
106+
columns,
107+
data, //data must be memoized or stable (useState, useMemo, defined outside of this component, etc.)
108+
});
109+
110+
return <>
111+
<CssBaseline />
112+
<AppBar position="sticky">
113+
<Toolbar>
114+
<p>App</p>
115+
</Toolbar>
116+
</AppBar>
117+
<Box padding={2}>
118+
<MaterialReactTable table={table} />
119+
</Box>
120+
</>;
121+
};
122+

0 commit comments

Comments
 (0)