@@ -404,21 +404,11 @@ function useDataGrid<TData>({
404404 }
405405 }
406406
407- // Determine the full range of indices to cover — including any rows
408- // that were just added by onRowsAdd and are in the table but may not
409- // yet be reflected in propsRef.current.data (stale closure timing).
410- const maxUpdateIndex =
411- rowUpdatesMap . size > 0
412- ? Math . max ( ...Array . from ( rowUpdatesMap . keys ( ) ) )
413- : - 1 ;
414- const dataLength = Math . max ( currentData . length , maxUpdateIndex + 1 ) ;
415-
416- const newData : TData [ ] = new Array ( dataLength ) ;
417-
418- for ( let i = 0 ; i < dataLength ; i ++ ) {
407+ const newData : TData [ ] = new Array ( currentData . length ) ;
408+
409+ for ( let i = 0 ; i < currentData . length ; i ++ ) {
419410 const updates = rowUpdatesMap . get ( i ) ;
420- // Fall back to the table's row data for rows not yet in currentData
421- const existingRow = currentData [ i ] ?? rows ?. [ i ] ?. original ;
411+ const existingRow = currentData [ i ] ;
422412
423413 if ( existingRow == null ) continue ;
424414
@@ -728,51 +718,13 @@ function useDataGrid<TData>({
728718 if ( ! clipboardText ) return ;
729719 }
730720
731- const rawPastedData = parseTsv (
732- clipboardText ,
733- navigableColumnIds . length ,
734- ) ;
735-
736- // When clipboard has exactly one cell and the user has multiple cells
737- // selected, fill the entire selection with that single value.
738- const selectionCells = currentState . selectionState . selectedCells ;
739- const isSingleCellClipboard =
740- rawPastedData . length === 1 && ( rawPastedData [ 0 ] ?. length ?? 0 ) === 1 ;
721+ const pastedData = parseTsv ( clipboardText , navigableColumnIds . length ) ;
741722
742- let pastedData = rawPastedData ;
743- let startRowIndex = currentState . focusedCell . rowIndex ;
744- let startColIndex = navigableColumnIds . indexOf (
723+ const startRowIndex = currentState . focusedCell . rowIndex ;
724+ const startColIndex = navigableColumnIds . indexOf (
745725 currentState . focusedCell . columnId ,
746726 ) ;
747727
748- if ( isSingleCellClipboard && selectionCells . size > 1 ) {
749- const singleValue = rawPastedData [ 0 ] ?. [ 0 ] ?? "" ;
750- let minRow = Infinity ;
751- let maxRow = - Infinity ;
752- let minColIdx = Infinity ;
753- let maxColIdx = - Infinity ;
754-
755- for ( const cellKey of selectionCells ) {
756- const { rowIndex, columnId } = parseCellKey ( cellKey ) ;
757- const colIdx = navigableColumnIds . indexOf ( columnId ) ;
758- if ( colIdx === - 1 ) continue ;
759- minRow = Math . min ( minRow , rowIndex ) ;
760- maxRow = Math . max ( maxRow , rowIndex ) ;
761- minColIdx = Math . min ( minColIdx , colIdx ) ;
762- maxColIdx = Math . max ( maxColIdx , colIdx ) ;
763- }
764-
765- if ( minRow !== Infinity ) {
766- startRowIndex = minRow ;
767- startColIndex = minColIdx ;
768- const numRows = maxRow - minRow + 1 ;
769- const numCols = maxColIdx - minColIdx + 1 ;
770- pastedData = Array . from ( { length : numRows } , ( ) =>
771- Array . from ( { length : numCols } , ( ) => singleValue ) ,
772- ) ;
773- }
774- }
775-
776728 if ( startColIndex === - 1 ) return ;
777729
778730 const rowCount = rows . length ?? propsRef . current . data . length ;
@@ -903,7 +855,7 @@ function useDataGrid<TData>({
903855 case "select" : {
904856 const options = cellOpts ?. options ?? [ ] ;
905857 if ( ! pastedValue ) {
906- processedValue = null ;
858+ processedValue = "" ;
907859 } else {
908860 const matched = matchSelectOption ( pastedValue , options ) ;
909861 if ( matched ) processedValue = matched ;
0 commit comments