@@ -3185,6 +3185,42 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
31853185
31863186 const overlayOpen = overlay !== undefined ;
31873187
3188+ const onContextMenu = React . useCallback (
3189+ ( args : GridMouseEventArgs , preventDefault : ( ) => void ) => {
3190+ const adjustedCol = args . location [ 0 ] - rowMarkerOffset ;
3191+ if ( args . kind === "header" ) {
3192+ onHeaderContextMenu ?.( adjustedCol , { ...args , preventDefault } ) ;
3193+ }
3194+
3195+ if ( args . kind === groupHeaderKind ) {
3196+ if ( adjustedCol < 0 ) {
3197+ return ;
3198+ }
3199+ onGroupHeaderContextMenu ?.( adjustedCol , { ...args , preventDefault } ) ;
3200+ }
3201+
3202+ if ( args . kind === "cell" ) {
3203+ const [ col , row ] = args . location ;
3204+ onCellContextMenu ?.( [ adjustedCol , row ] , {
3205+ ...args ,
3206+ preventDefault,
3207+ } ) ;
3208+
3209+ if ( ! gridSelectionHasItem ( gridSelection , args . location ) ) {
3210+ updateSelectedCell ( col , row , false , false ) ;
3211+ }
3212+ }
3213+ } ,
3214+ [
3215+ gridSelection ,
3216+ onCellContextMenu ,
3217+ onGroupHeaderContextMenu ,
3218+ onHeaderContextMenu ,
3219+ rowMarkerOffset ,
3220+ updateSelectedCell ,
3221+ ]
3222+ ) ;
3223+
31883224 const handleFixedKeybindings = React . useCallback (
31893225 ( event : GridKeyEventArgs ) : boolean => {
31903226 const cancel = ( ) => {
@@ -3480,6 +3516,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
34803516 return didMatch ;
34813517 } ,
34823518 [
3519+ onContextMenu ,
34833520 rowGroupingNavBehavior ,
34843521 overlayOpen ,
34853522 gridSelection ,
@@ -3573,42 +3610,6 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
35733610 ]
35743611 ) ;
35753612
3576- const onContextMenu = React . useCallback (
3577- ( args : GridMouseEventArgs , preventDefault : ( ) => void ) => {
3578- const adjustedCol = args . location [ 0 ] - rowMarkerOffset ;
3579- if ( args . kind === "header" ) {
3580- onHeaderContextMenu ?.( adjustedCol , { ...args , preventDefault } ) ;
3581- }
3582-
3583- if ( args . kind === groupHeaderKind ) {
3584- if ( adjustedCol < 0 ) {
3585- return ;
3586- }
3587- onGroupHeaderContextMenu ?.( adjustedCol , { ...args , preventDefault } ) ;
3588- }
3589-
3590- if ( args . kind === "cell" ) {
3591- const [ col , row ] = args . location ;
3592- onCellContextMenu ?.( [ adjustedCol , row ] , {
3593- ...args ,
3594- preventDefault,
3595- } ) ;
3596-
3597- if ( ! gridSelectionHasItem ( gridSelection , args . location ) ) {
3598- updateSelectedCell ( col , row , false , false ) ;
3599- }
3600- }
3601- } ,
3602- [
3603- gridSelection ,
3604- onCellContextMenu ,
3605- onGroupHeaderContextMenu ,
3606- onHeaderContextMenu ,
3607- rowMarkerOffset ,
3608- updateSelectedCell ,
3609- ]
3610- ) ;
3611-
36123613 const onPasteInternal = React . useCallback (
36133614 async ( e ?: ClipboardEvent ) => {
36143615 if ( ! keybindings . paste ) return ;
0 commit comments