@@ -350,16 +350,17 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
350350 } ;
351351
352352 // Cell editing handlers
353- const startEdit = ( rowIndex : number , columnKey : string , currentValue : any ) => {
353+ const startEdit = ( rowIndex : number , columnKey : string ) => {
354354 if ( ! editable ) return ;
355355
356356 const column = columns . find ( col => col . accessorKey === columnKey ) ;
357357 if ( column ?. editable === false ) return ;
358358
359359 setEditingCell ( { rowIndex, columnKey } ) ;
360360
361- // Check if there's a pending change for this cell
361+ // Check if there's a pending change for this cell, otherwise use current data value
362362 const rowChanges = pendingChanges . get ( rowIndex ) ;
363+ const currentValue = paginatedData [ rowIndex ] [ columnKey ] ;
363364 const valueToEdit = rowChanges ?. [ columnKey ] ?? currentValue ?? '' ;
364365 setEditValue ( valueToEdit ) ;
365366 } ;
@@ -461,8 +462,7 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
461462
462463 if ( e . key === 'Enter' && ! editingCell ) {
463464 e . preventDefault ( ) ;
464- const value = paginatedData [ rowIndex ] [ columnKey ] ;
465- startEdit ( rowIndex , columnKey , value ) ;
465+ startEdit ( rowIndex , columnKey ) ;
466466 }
467467 } ;
468468
@@ -707,7 +707,7 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
707707 minWidth : columnWidth ,
708708 maxWidth : columnWidth
709709 } }
710- onDoubleClick = { ( ) => isEditable && startEdit ( rowIndex , col . accessorKey , originalValue ) }
710+ onDoubleClick = { ( ) => isEditable && startEdit ( rowIndex , col . accessorKey ) }
711711 onKeyDown = { ( e ) => handleCellKeyDown ( e , rowIndex , col . accessorKey ) }
712712 tabIndex = { 0 }
713713 >
0 commit comments