@@ -478,6 +478,10 @@ export function TableGrid({
478478 const params = useParams ( )
479479 const workspaceId = propWorkspaceId || ( params . workspaceId as string )
480480 const tableId = propTableId || ( params . tableId as string )
481+ const workspaceIdRef = useRef ( workspaceId )
482+ workspaceIdRef . current = workspaceId
483+ const tableIdRef = useRef ( tableId )
484+ tableIdRef . current = tableId
481485 const posthog = usePostHog ( )
482486
483487 useEffect ( ( ) => {
@@ -3403,12 +3407,12 @@ export function TableGrid({
34033407 const selectedRows = currentRows . filter ( ( row ) => rowSelectionIncludes ( rowSel , row . id ) )
34043408 const handled = writeLoadedRowsWithChip ( {
34053409 clipboardData : e . clipboardData ,
3406- workspaceId,
3410+ workspaceId : workspaceIdRef . current ,
34073411 rows : selectedRows ,
34083412 complete : true ,
34093413 buildCells : ( row ) => cols . map ( ( col ) => cellToText ( row . data [ col . key ] , col ) ) ,
34103414 context : buildTableSelectionContext ( {
3411- tableId,
3415+ tableId : tableIdRef . current ,
34123416 tableName : tableNameRef . current ,
34133417 // Every selected id, not just the loaded page: the chip carries
34143418 // ids and the server re-fetches them, so an unloaded row still
@@ -3451,13 +3455,13 @@ export function TableGrid({
34513455 // in the rest — so the chip path applies only once all of them are here.
34523456 const handled = writeLoadedRowsWithChip ( {
34533457 clipboardData : e . clipboardData ,
3454- workspaceId,
3458+ workspaceId : workspaceIdRef . current ,
34553459 rows : currentRows ,
34563460 complete : currentRows . length >= selectAllTotalRef . current ,
34573461 buildCells : ( row ) =>
34583462 colNames . map ( ( name ) => cellToText ( row . data [ name ] , colByKey . get ( name ) ) ) ,
34593463 context : buildTableSelectionContext ( {
3460- tableId,
3464+ tableId : tableIdRef . current ,
34613465 tableName : tableNameRef . current ,
34623466 rowIds : currentRows . map ( ( row ) => row . id ) ,
34633467 columnIds : selectedColumnIds ( cols , sel ) ,
@@ -3484,13 +3488,13 @@ export function TableGrid({
34843488 if ( row ) rangeRowIds . push ( row . id )
34853489 }
34863490 const rangeContext = buildTableSelectionContext ( {
3487- tableId,
3491+ tableId : tableIdRef . current ,
34883492 tableName : tableNameRef . current ,
34893493 rowIds : rangeRowIds ,
34903494 columnIds : selectedColumnIds ( cols , sel ) ,
34913495 } )
34923496 if ( rangeContext ) {
3493- attachSelectionContextToClipboard ( e . clipboardData , rangeContext , workspaceId )
3497+ attachSelectionContextToClipboard ( e . clipboardData , rangeContext , workspaceIdRef . current )
34943498 }
34953499
34963500 const lines : string [ ] = [ ]
0 commit comments