@@ -617,6 +617,8 @@ type ScrollToFn = (
617617 }
618618) => void ;
619619
620+ type EnterCellEditModeFn = ( location : Item , initialValue ?: string ) => void ;
621+
620622/** @category DataEditor */
621623export interface DataEditorRef {
622624 /**
@@ -645,6 +647,10 @@ export interface DataEditorRef {
645647 * Scrolls to the desired cell or location in the grid.
646648 */
647649 scrollTo : ScrollToFn ;
650+ /**
651+ * Enters edit mode of the provided cell.
652+ */
653+ enterCellEditMode : EnterCellEditModeFn ;
648654}
649655
650656const loadingCell : GridCell = {
@@ -1523,6 +1529,27 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15231529 [ mangledCols , onRowAppended , rowMarkerOffset , rows , scrollTo , setCurrent ]
15241530 ) ;
15251531
1532+ const enterCellEditMode : EnterCellEditModeFn = React . useCallback (
1533+ ( [ col , row ] , initialValue ) : void => {
1534+
1535+ const cell = getCellContentRef . current ( [ col - rowMarkerOffset , row ] ) ;
1536+ const bounds = gridRef . current ?. getBounds ( col , row ) ;
1537+
1538+ if ( cell . allowOverlay && isReadWriteCell ( cell ) && cell . readonly !== true && bounds ) {
1539+ setOverlaySimple ( {
1540+ target : bounds ,
1541+ content : cell ,
1542+ initialValue,
1543+ cell : [ col , row ] ,
1544+ highlight : true ,
1545+ forceEditMode : true ,
1546+ } ) ;
1547+ }
1548+
1549+ } ,
1550+ [ rowMarkerOffset , setOverlaySimple ]
1551+ ) ;
1552+
15261553 const getCustomNewRowTargetColumn = React . useCallback (
15271554 ( col : number ) : number | undefined => {
15281555 const customTargetColumn =
@@ -3357,6 +3384,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
33573384 return gridRef . current ?. getBounds ( col + rowMarkerOffset , row ) ;
33583385 } ,
33593386 focus : ( ) => gridRef . current ?. focus ( ) ,
3387+ enterCellEditMode,
33603388 emit : async e => {
33613389 switch ( e ) {
33623390 case "delete" :
@@ -3417,7 +3445,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
34173445 } ,
34183446 scrollTo,
34193447 } ) ,
3420- [ appendRow , onCopy , onKeyDown , onPasteInternal , rowMarkerOffset , scrollTo ]
3448+ [ appendRow , enterCellEditMode , onCopy , onKeyDown , onPasteInternal , rowMarkerOffset , scrollTo ]
34213449 ) ;
34223450
34233451 const [ selCol , selRow ] = currentCell ?? [ ] ;
0 commit comments