@@ -309,7 +309,7 @@ export default function TimeTableRows<
309309 if (
310310 ( renderedGroup < newRenderCells [ 0 ] ||
311311 renderedGroup > newRenderCells [ 1 ] ) &&
312- renderedGroup < currentGroupRows . size
312+ renderedGroup < currentGroupRowsRef . current . size
313313 ) {
314314 changedGroupRows . current . add ( renderedGroup )
315315 }
@@ -318,7 +318,8 @@ export default function TimeTableRows<
318318 if ( newRenderCells [ 0 ] > - 1 ) {
319319 for (
320320 let i = newRenderCells [ 0 ] ;
321- i <= newRenderCells [ 1 ] && i < currentGroupRows . size ;
321+ i <= newRenderCells [ 1 ] &&
322+ i < currentGroupRowsRef . current . size ;
322323 i ++
323324 ) {
324325 if ( ! renderedGroups . current . has ( i ) ) {
@@ -331,6 +332,8 @@ export default function TimeTableRows<
331332 prev ,
332333 "to" ,
333334 newRenderCells ,
335+ changedGroupRows . current ,
336+ currentGroupRowsRef . current ,
334337 )
335338 renderGroupRangeRef . current = newRenderCells
336339 return newRenderCells
@@ -339,9 +342,8 @@ export default function TimeTableRows<
339342 } )
340343 } , [ intersectionContainerRef . current , headerRef . current , rowHeight ] )
341344
342- // const currentGroupRows = useRef(groupRows)
345+ const currentGroupRowsRef = useRef ( groupRows )
343346 const [ currentGroupRows , setCurrentGroupRows ] = useState ( groupRows )
344- //const [currentGroupRows, setCurrentGroupRows] = useState(groupRows)
345347
346348 //** ------- CHANGE DETECTION ------ */
347349 // handle changes in the group rows
@@ -371,7 +373,6 @@ export default function TimeTableRows<
371373 }
372374
373375 // determine when new ones start
374- const perf_Start = performance . now ( )
375376 let changedFound = - 1
376377 const keys = groupRows . keys ( ) . toArray ( )
377378 let updateCounter = 0
@@ -411,6 +412,8 @@ export default function TimeTableRows<
411412 `TimeTable - group rows require updated rendering ${ updateCounter } , with first ${ changedFound } ` ,
412413 )
413414 }
415+ console . log ( "SET CURRENT GROUP ROWS" , groupRows )
416+ currentGroupRowsRef . current = groupRows
414417 return groupRows
415418 } )
416419 }
@@ -454,22 +457,23 @@ export default function TimeTableRows<
454457 const renderBatch = useCallback ( ( ) => {
455458 setGroupRowsRenderedIdx ( ( groupRowsRenderedIdx ) => {
456459 if ( changedGroupRows . current . size ) {
460+ console . log ( "RENDERING" , changedGroupRows . current )
457461 let counter = 0
458462 if ( renderGroupRangeRef . current [ 0 ] > - 1 ) {
459463 for (
460464 let i = renderGroupRangeRef . current [ 0 ] ;
461465 i <= renderGroupRangeRef . current [ 1 ] ;
462466 i ++
463467 ) {
464- if ( i > currentGroupRows . size - 1 ) {
468+ if ( i > currentGroupRowsRef . current . size - 1 ) {
465469 changedGroupRows . current . delete ( i )
466470 continue
467471 }
468472 // make sure visible rows are rendered
469473 if ( changedGroupRows . current . has ( i ) ) {
470474 renderGroupRows (
471475 renderGroupRangeRef . current ,
472- currentGroupRows ,
476+ currentGroupRowsRef . current ,
473477 i ,
474478 refCollection . current ,
475479 groupRowsRendered . current ,
@@ -493,14 +497,17 @@ export default function TimeTableRows<
493497 }
494498 }
495499 for ( const g of changedGroupRows . current ) {
496- if ( g > currentGroupRows . size - 1 ) {
500+ if (
501+ g > currentGroupRowsRef . current . size - 1 ||
502+ g > groupRowsRenderedIdxRef . current
503+ ) {
497504 changedGroupRows . current . delete ( g )
498505 continue
499506 }
500507 // unrender not visible rows, but render only if the placeholders are already rendered)
501508 renderGroupRows (
502509 renderGroupRangeRef . current ,
503- currentGroupRows ,
510+ currentGroupRowsRef . current ,
504511 g ,
505512 refCollection . current ,
506513 groupRowsRendered . current ,
@@ -527,12 +534,12 @@ export default function TimeTableRows<
527534 let ret = groupRowsRendered . current . length
528535 let counter = 0
529536 while (
530- ret < currentGroupRows . size &&
537+ ret < currentGroupRowsRef . current . size &&
531538 counter < timeTableGroupRenderBatchSize
532539 ) {
533540 renderGroupRows (
534541 renderGroupRangeRef . current ,
535- currentGroupRows ,
542+ currentGroupRowsRef . current ,
536543 ret ,
537544 refCollection . current ,
538545 groupRowsRendered . current ,
@@ -565,7 +572,6 @@ export default function TimeTableRows<
565572 slotsArray ,
566573 timeFrameDay ,
567574 viewType ,
568- currentGroupRows ,
569575 handleIntersections ,
570576 rateLimiterIntersection ,
571577 ] )
0 commit comments