@@ -281,6 +281,7 @@ function FilterDataTable({
281281
282282 return {
283283 ...baseCol ,
284+ width : col == 'ls_index' ? 60 : 150 ,
284285 renderCell,
285286 } ;
286287 } ) ;
@@ -307,69 +308,6 @@ function FilterDataTable({
307308 hydrateIndices ( indicesToUse ) ;
308309 } , [ filteredIndices , page , defaultIndices , deletedIndices , hydrateIndices ] ) ;
309310
310- const headerRef = useRef ( null ) ;
311- const bodyRef = useRef ( null ) ;
312-
313- const [ scrollbarWidth , setScrollbarWidth ] = useState ( 0 ) ;
314-
315- const calculateScrollbarWidth = ( ) => {
316- if ( bodyRef . current ) {
317- const width = bodyRef . current . offsetWidth - bodyRef . current . clientWidth ;
318- setScrollbarWidth ( width ) ;
319- }
320- } ;
321-
322- // these useEffects seem janky. I want to have the table body scroll independently in Y but not in X
323- useEffect ( ( ) => {
324- calculateScrollbarWidth ( ) ;
325- // Recalculate on window resize
326- window . addEventListener ( 'resize' , calculateScrollbarWidth ) ;
327-
328- // Adjust header width to match body's scrollWidth
329- const adjustHeaderWidth = ( ) => {
330- if ( headerRef . current && bodyRef . current ) {
331- const bodyScrollWidth = bodyRef . current . scrollWidth ;
332- headerRef . current . querySelector ( 'table' ) . style . width = `${ bodyScrollWidth } px` ;
333- headerRef . current . style . overflowX = 'hidden' ; // Hide horizontal overflow
334- }
335- } ;
336-
337- // Call it initially and whenever the window resizes
338- adjustHeaderWidth ( ) ;
339- window . addEventListener ( 'resize' , adjustHeaderWidth ) ;
340- const resizeObserver = new ResizeObserver ( ( entries ) => {
341- for ( let entry of entries ) {
342- if ( entry . target === bodyRef . current ) {
343- adjustHeaderWidth ( ) ;
344- }
345- }
346- } ) ;
347-
348- if ( bodyRef . current ) {
349- resizeObserver . observe ( bodyRef . current ) ;
350- }
351-
352- // Start: Code to synchronize horizontal scroll
353- const syncHorizontalScroll = ( ) => {
354- if ( headerRef . current && bodyRef . current ) {
355- headerRef . current . scrollLeft = bodyRef . current . scrollLeft ;
356- }
357- } ;
358-
359- const bodyEl = bodyRef . current ;
360- bodyEl . addEventListener ( 'scroll' , syncHorizontalScroll ) ;
361-
362- // End: Code to synchronize horizontal scroll
363-
364- return ( ) => {
365- window . removeEventListener ( 'resize' , calculateScrollbarWidth ) ;
366- window . removeEventListener ( 'resize' , adjustHeaderWidth ) ;
367- // Clean up the scroll listener
368- bodyEl . removeEventListener ( 'scroll' , syncHorizontalScroll ) ;
369- resizeObserver . disconnect ( ) ;
370- } ;
371- } , [ ] ) ;
372-
373311 const renderRowWithHover = useCallback (
374312 ( key , props ) => {
375313 return < RowWithHover key = { key } props = { props } onHover = { onHover } /> ;
@@ -395,11 +333,7 @@ function FilterDataTable({
395333 // style={{ visibility: indices.length ? 'visible' : 'hidden' }}
396334 >
397335 { /* Scrollable Table Body */ }
398- < div
399- className = "filter-table-scrollable-body table-body"
400- style = { { overflowY : 'auto' } }
401- ref = { bodyRef }
402- >
336+ < div className = "filter-table-scrollable-body table-body" style = { { overflowY : 'auto' } } >
403337 < DataGrid
404338 rows = { rows }
405339 columns = { formattedColumns }
0 commit comments