dev: datatable wasn't adapting to screen changes

Massimo Melina committed Apr 17, 2024 at 16:22 UTC ac3467eeef15aa13ae91732ab30ca258780d9388
1 file changed +2 -1
admin/src/DataTable.ts
+2 -1
@@ -24,7 +24,8 @@ interface DataTableProps<R extends GridValidRowModel=any> extends Omit<DataGridP
24 addToFooter?: ReactNode
25 }
26 export function DataTable({ columns, initialState={}, actions, actionsProps, initializing, noRows, error, compact, addToFooter, ...rest }: DataTableProps) {
27 - useWindowSize(); const width = window.outerWidth // workaround: width returned by useWindowSize is not good
27 + let { width } = useWindowSize()
28 + width = Math.min(width, screen.availWidth) // workaround: width returned by useWindowSize is not good when toggling mobile-mode in chrome
29 const theme = useTheme()
30 const apiRef = useGridApiRef()
31 const [actionsLength, setActionsLength] = useState(0)