@@ -62,6 +62,23 @@ const useStyles = makeStyles(() => {
6262 } ;
6363} ) ;
6464
65+ const shouldShowCompactMobileView = ( width : number ) => {
66+ return width < MOBILE_VIEW_THRESHOLD ;
67+ } ;
68+
69+ /** Use to make sure we don't cut the table off by having other UI elements enabled */
70+ export const getTableUIElementsOffset = ( {
71+ showSearch,
72+ width,
73+ } : {
74+ showSearch : boolean ;
75+ width : number ;
76+ } ) => {
77+ return (
78+ ( showSearch ? 48 : 0 ) + ( shouldShowCompactMobileView ( width ) ? 48 : 0 ) + 4
79+ ) ;
80+ } ;
81+
6582export const Table = ( ) => {
6683 const {
6784 bounds,
@@ -78,8 +95,7 @@ export const Table = () => {
7895
7996 const [ compactMobileViewEnabled , setCompactMobileView ] = useState ( false ) ;
8097
81- const showCompactMobileView =
82- bounds . width < MOBILE_VIEW_THRESHOLD && compactMobileViewEnabled ;
98+ const showCompactMobileView = shouldShowCompactMobileView ( bounds . width ) ;
8399
84100 // Search & filter data
85101 const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
@@ -211,7 +227,7 @@ export const Table = () => {
211227 style : {
212228 ...style ,
213229 flexDirection : "column" ,
214- width : "max-content " ,
230+ width : "100% " ,
215231 } ,
216232 } ) }
217233 >
@@ -281,6 +297,10 @@ export const Table = () => {
281297 tableColumnsMeta ,
282298 ]
283299 ) ;
300+ const defaultListHeightOffset = getTableUIElementsOffset ( {
301+ showSearch,
302+ width : bounds . width ,
303+ } ) ;
284304
285305 return (
286306 < >
@@ -311,7 +331,7 @@ export const Table = () => {
311331 />
312332 </ Box >
313333
314- { showCompactMobileView ? (
334+ { showCompactMobileView && compactMobileViewEnabled ? (
315335 /* Compact Mobile View */
316336 < Box
317337 sx = { {
@@ -327,7 +347,7 @@ export const Table = () => {
327347 { ( { width, height } : { width : number ; height : number } ) => (
328348 < VariableSizeList
329349 key = { rows . length } // Reset when groups are toggled because itemSize remains cached per index
330- height = { height }
350+ height = { height - defaultListHeightOffset }
331351 itemCount = { rows . length }
332352 itemSize = { getMobileItemSize }
333353 width = { width }
@@ -359,7 +379,8 @@ export const Table = () => {
359379 { ( { height } : { height : number } ) => (
360380 < FixedSizeList
361381 outerElementType = { TableContentWrapper }
362- height = { height }
382+ // row height = header row height
383+ height = { height - defaultListHeightOffset - rowHeight }
363384 itemCount = { rows . length }
364385 itemSize = { rowHeight } // depends on whether a column has bars (40px or 56px)
365386 width = "100%"
0 commit comments