material-react-table 1.0.0-beta.7 → 1.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.7",
2
+ "version": "1.0.0-beta.8",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -1,4 +1,4 @@
1
- import React, { FC, useEffect } from 'react';
1
+ import React, { FC } from 'react';
2
2
  import { Paper } from '@mui/material';
3
3
  import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
4
4
  import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
@@ -17,16 +17,6 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
17
17
  } = table;
18
18
  const { isFullScreen } = getState();
19
19
 
20
- useEffect(() => {
21
- if (typeof window !== 'undefined') {
22
- if (isFullScreen) {
23
- document.body.style.height = '100vh';
24
- } else {
25
- document.body.style.height = 'auto';
26
- }
27
- }
28
- }, [isFullScreen]);
29
-
30
20
  const tablePaperProps =
31
21
  muiTablePaperProps instanceof Function
32
22
  ? muiTablePaperProps({ table })
@@ -51,12 +41,16 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
51
41
  })}
52
42
  style={{
53
43
  ...tablePaperProps?.style,
54
- height: isFullScreen ? '100vh' : undefined,
55
- margin: isFullScreen ? '0' : undefined,
56
- maxHeight: isFullScreen ? '100vh' : undefined,
57
- maxWidth: isFullScreen ? '100vw' : undefined,
58
- padding: isFullScreen ? '0' : undefined,
59
- width: isFullScreen ? '100vw' : undefined,
44
+ ...(isFullScreen
45
+ ? {
46
+ height: '100vh',
47
+ margin: 0,
48
+ maxHeight: '100vh',
49
+ maxWidth: '100vw',
50
+ padding: 0,
51
+ width: '100vw',
52
+ }
53
+ : {}),
60
54
  }}
61
55
  >
62
56
  {enableTopToolbar && <MRT_TopToolbar table={table} />}
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useRef, useState } from 'react';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import {
3
3
  TableState,
4
4
  getCoreRowModel,
@@ -315,6 +315,24 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
315
315
  props.tableInstanceRef.current = table;
316
316
  }
317
317
 
318
+ const initialBodyHeight = useRef<string>();
319
+
320
+ useEffect(() => {
321
+ if (typeof window !== 'undefined') {
322
+ initialBodyHeight.current = document.body.style.height;
323
+ }
324
+ }, []);
325
+
326
+ useEffect(() => {
327
+ if (typeof window !== 'undefined') {
328
+ if (table.getState().isFullScreen) {
329
+ document.body.style.height = '100vh';
330
+ } else {
331
+ document.body.style.height = initialBodyHeight.current as string;
332
+ }
333
+ }
334
+ }, [table.getState().isFullScreen]);
335
+
318
336
  return (
319
337
  <>
320
338
  <Dialog