@@ -31,7 +31,7 @@ import {
3131 BooleanIndeterminate ,
3232 type FillHandleDirection ,
3333 type EditListItem ,
34- type CellActiviationBehavior ,
34+ type CellActivationBehavior ,
3535} from "../internal/data-grid/data-grid-types.js" ;
3636import DataGridSearch , { type DataGridSearchProps } from "../internal/data-grid-search/data-grid-search.js" ;
3737import { browserIsOSX } from "../common/browser-detect.js" ;
@@ -78,6 +78,7 @@ import {
7878 type GridDragEventArgs ,
7979 mouseEventArgsAreEqual ,
8080 type GridKeyEventArgs ,
81+ type CellActivatedEventArgs ,
8182} from "../internal/data-grid/event-args.js" ;
8283import { type Keybinds , useKeybindingsWithDefaults } from "./data-editor-keybindings.js" ;
8384import type { Highlight } from "../internal/data-grid/render/data-grid-render.cells.js" ;
@@ -241,7 +242,7 @@ export interface DataEditorProps extends Props, Pick<DataGridSearchProps, "image
241242 /** Emitted when a cell is activated, by pressing Enter, Space or double clicking it.
242243 * @group Events
243244 */
244- readonly onCellActivated ?: ( cell : Item ) => void ;
245+ readonly onCellActivated ?: ( cell : Item , event : CellActivatedEventArgs ) => void ;
245246
246247 /**
247248 * Emitted whenever the user initiats a pattern fill using the fill handle. This event provides both
@@ -663,7 +664,7 @@ export interface DataEditorProps extends Props, Pick<DataGridSearchProps, "image
663664 * Determines when a cell is considered activated and will emit the `onCellActivated` event. Generally an activated
664665 * cell will open to edit mode.
665666 */
666- readonly cellActivationBehavior ?: CellActiviationBehavior ;
667+ readonly cellActivationBehavior ?: CellActivationBehavior ;
667668
668669 /**
669670 * Controls if focus will trap inside the data grid when doing tab and caret navigation.
@@ -771,6 +772,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
771772 cell : Item ;
772773 highlight : boolean ;
773774 forceEditMode : boolean ;
775+ activation : CellActivatedEventArgs ;
774776 } > ( ) ;
775777 const searchInputRef = React . useRef < HTMLInputElement | null > ( null ) ;
776778 const canvasRef = React . useRef < HTMLCanvasElement | null > ( null ) ;
@@ -1431,7 +1433,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
14311433 ) ;
14321434
14331435 const reselect = React . useCallback (
1434- ( bounds : Rectangle , fromKeyboard : boolean , initialValue ?: string ) => {
1436+ ( bounds : Rectangle , activation : CellActivatedEventArgs , initialValue ?: string ) => {
14351437 if ( gridSelection . current === undefined ) return ;
14361438
14371439 const [ col , row ] = gridSelection . current . cell ;
@@ -1466,8 +1468,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
14661468 cell : [ col , row ] ,
14671469 highlight : initialValue === undefined ,
14681470 forceEditMode : initialValue !== undefined ,
1471+ activation,
14691472 } ) ;
1470- } else if ( c . kind === GridCellKind . Boolean && fromKeyboard && c . readonly !== true ) {
1473+ } else if ( c . kind === GridCellKind . Boolean && activation . inputType === "keyboard" && c . readonly !== true ) {
14711474 mangledOnCellsEdited ( [
14721475 {
14731476 location : gridSelection . current . cell ,
@@ -1502,6 +1505,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15021505 highlight : true ,
15031506 cell : [ col , row ] ,
15041507 forceEditMode : true ,
1508+ activation : { inputType : "keyboard" , key : "Enter" } ,
15051509 } ) ;
15061510 } ,
15071511 [ getMangledCellContent , scrollRef , setOverlaySimple ]
@@ -2058,6 +2062,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
20582062 mapper ,
20592063 lastRowSticky ,
20602064 setCurrent ,
2065+ headerRowMarkerDisabled ,
20612066 setSelectedColumns ,
20622067 setGridSelection ,
20632068 onSelectionCleared ,
@@ -2387,8 +2392,16 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
23872392 }
23882393 }
23892394 if ( shouldActivate ) {
2390- onCellActivated ?.( [ col - rowMarkerOffset , row ] ) ;
2391- reselect ( a . bounds , false ) ;
2395+ const act = a . isDoubleClick === true
2396+ ? "double-click"
2397+ : ( c . activationBehaviorOverride ?? cellActivationBehavior ) ;
2398+ const activationEvent : CellActivatedEventArgs = {
2399+ inputType : "pointer" ,
2400+ pointerActivation : act ,
2401+ pointerType : a . isTouch ? "touch" : "mouse" ,
2402+ } ;
2403+ onCellActivated ?.( [ col - rowMarkerOffset , row ] , activationEvent ) ;
2404+ reselect ( a . bounds , activationEvent ) ;
23922405 return true ;
23932406 }
23942407 }
@@ -3265,8 +3278,12 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
32653278 void appendRow ( customTargetColumn ?? col ) ;
32663279 } , 0 ) ;
32673280 } else {
3268- onCellActivated ?.( [ col - rowMarkerOffset , row ] ) ;
3269- reselect ( bounds , true ) ;
3281+ const activationEvent : CellActivatedEventArgs = {
3282+ inputType : "keyboard" ,
3283+ key : event . key ,
3284+ } ;
3285+ onCellActivated ?.( [ col - rowMarkerOffset , row ] , activationEvent ) ;
3286+ reselect ( bounds , activationEvent ) ;
32703287 }
32713288 } else if ( gridSelection . current . range . height > 1 && isHotkey ( keys . downFill , event , details ) ) {
32723289 fillDown ( ) ;
@@ -3477,8 +3494,12 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
34773494 ) {
34783495 return ;
34793496 }
3480- onCellActivated ?.( [ col - rowMarkerOffset , row ] ) ;
3481- reselect ( event . bounds , true , event . key ) ;
3497+ const activationEvent : CellActivatedEventArgs = {
3498+ inputType : "keyboard" ,
3499+ key : event . key ,
3500+ } ;
3501+ onCellActivated ?.( [ col - rowMarkerOffset , row ] , activationEvent ) ;
3502+ reselect ( event . bounds , activationEvent , event . key ) ;
34823503 event . stopPropagation ( ) ;
34833504 event . preventDefault ( ) ;
34843505 }
@@ -3543,7 +3564,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
35433564 formatted ?: string | string [ ]
35443565 ) : EditListItem | undefined {
35453566 const stringifiedRawValue =
3546- typeof rawValue === "object" ? rawValue ?. join ( "\n" ) ?? "" : rawValue ?. toString ( ) ?? "" ;
3567+ typeof rawValue === "object" ? ( rawValue ?. join ( "\n" ) ?? "" ) : ( rawValue ?. toString ( ) ?? "" ) ;
35473568
35483569 if ( ! isInnerOnlyCell ( inner ) && isReadWriteCell ( inner ) && inner . readonly !== true ) {
35493570 const coerced = coercePasteValue ?.( stringifiedRawValue , inner ) ;
0 commit comments