@@ -276,7 +276,7 @@ An array of rows, the rows data can be of any type.
276276
277277###### ` ref?: Maybe<React.Ref<DataGridHandle>> `
278278
279- Optional ref for imperative APIs like scrolling/selecting a cell. See [ ` DataGridHandle ` ] ( #datagridhandle ) .
279+ Optional ref for imperative APIs like scrolling to or focusing a cell. See [ ` DataGridHandle ` ] ( #datagridhandle ) .
280280
281281###### ` topSummaryRows?: Maybe<readonly SR[]> `
282282
@@ -507,11 +507,9 @@ function MyGrid() {
507507}
508508```
509509
510- ###### ` onFill?: Maybe<(event: FillEvent<R>) => R> `
511-
512510###### ` onCellMouseDown?: CellMouseEventHandler<R, SR> `
513511
514- Callback triggered when a pointer becomes active in a cell. The default behavior is to select the cell. Call ` preventGridDefault ` to prevent the default behavior.
512+ Callback triggered when a pointer becomes active in a cell. The default behavior is to focus the cell. Call ` preventGridDefault ` to prevent the default behavior.
515513
516514``` tsx
517515function onCellMouseDown(args : CellMouseArgs <R , SR >, event : CellMouseEvent ) {
@@ -542,7 +540,7 @@ This event can be used to open cell editor on single click
542540``` tsx
543541function onCellClick(args : CellMouseArgs <R , SR >, event : CellMouseEvent ) {
544542 if (args .column .key === ' id' ) {
545- args .selectCell (true );
543+ args .setActivePosition (true );
546544 }
547545}
548546```
@@ -586,7 +584,7 @@ A function called when keydown event is triggered on a cell. This event can be u
586584
587585``` tsx
588586function onCellKeyDown(args : CellKeyDownArgs <R , SR >, event : CellKeyboardEvent ) {
589- if (args .mode === ' SELECT ' && event .key === ' Enter' ) {
587+ if (args .mode === ' ACTIVE ' && event .key === ' Enter' ) {
590588 event .preventGridDefault ();
591589 }
592590}
@@ -596,7 +594,7 @@ function onCellKeyDown(args: CellKeyDownArgs<R, SR>, event: CellKeyboardEvent) {
596594
597595``` tsx
598596function onCellKeyDown(args : CellKeyDownArgs <R , SR >, event : CellKeyboardEvent ) {
599- if (args .mode === ' SELECT ' && event .key === ' Tab' ) {
597+ if (args .mode === ' ACTIVE ' && event .key === ' Tab' ) {
600598 event .preventGridDefault ();
601599 }
602600}
@@ -614,15 +612,13 @@ Callback triggered when content is pasted into a cell.
614612
615613Return the updated row; the grid will call ` onRowsChange ` with it.
616614
617- ###### ` onSelectedCellChange ?: Maybe<(args: CellSelectArgs <R, SR>) => void>`
615+ ###### ` onActivePositionChange ?: Maybe<(args: PositionChangeArgs <R, SR>) => void>`
618616
619- Triggered when the selected cell is changed .
617+ Triggered when the active position changes .
620618
621- Arguments:
619+ See the [ ` PositionChangeArgs ` ] ( #positionchangeargstrow-tsummaryrow ) type in the Types section below.
622620
623- - ` args.rowIdx ` : ` number ` - row index
624- - ` args.row ` : ` R | undefined ` - row object of the currently selected cell
625- - ` args.column ` : ` CalculatedColumn<TRow, TSummaryRow> ` - column object of the currently selected cell
621+ ###### ` onFill?: Maybe<(event: FillEvent<R>) => R> `
626622
627623###### ` onScroll?: Maybe<(event: React.UIEvent<HTMLDivElement>) => void> `
628624
@@ -1374,7 +1370,7 @@ Control whether cells can be edited with `renderEditCell`.
13741370
13751371##### ` colSpan?: Maybe<(args: ColSpanArgs<TRow, TSummaryRow>) => Maybe<number>> `
13761372
1377- Function to determine how many columns this cell should span. Returns the number of columns to span, or ` undefined ` for no spanning. See the ` ColSpanArgs ` type in the Types section below.
1373+ Function to determine how many columns this cell should span. Returns the number of columns to span, or ` undefined ` for no spanning. See the [ ` ColSpanArgs ` ] ( #colspanargstrow-tsummaryrow ) type in the Types section below.
13781374
13791375** Example:**
13801376
@@ -1587,7 +1583,7 @@ interface RenderEditCellContentProps<TRow, TSummaryRow = unknown> {
15871583 row: TRow ;
15881584 rowIdx: number ;
15891585 onRowChange: (row : TRow , commitChanges ? : boolean ) => void ;
1590- onClose: (commitChanges ? : boolean , shouldFocusCell ? : boolean ) => void ;
1586+ onClose: (commitChanges ? : boolean , shouldFocus ? : boolean ) => void ;
15911587}
15921588```
15931589
@@ -1643,17 +1639,17 @@ Props passed to custom row renderers.
16431639``` tsx
16441640interface RenderRowProps <TRow , TSummaryRow = unknown > {
16451641 row: TRow ;
1646- viewportColumns : readonly CalculatedColumn <TRow , TSummaryRow >[] ;
1642+ iterateOverViewportColumnsForRow : IterateOverViewportColumnsForRow <TRow , TSummaryRow >;
16471643 rowIdx: number ;
1648- selectedCellIdx: number | undefined ;
1649- isRowSelected: boolean ;
1644+ activeCellIdx: number | undefined ;
16501645 isRowSelectionDisabled: boolean ;
1646+ isRowSelected: boolean ;
16511647 gridRowStart: number ;
1652- lastFrozenColumnIndex: number ;
16531648 draggedOverCellIdx: number | undefined ;
1654- selectedCellEditor : ReactElement <EditCellProps <TRow , TSummaryRow >> | undefined ;
1649+ activeCellEditor : ReactElement <EditCellProps <TRow , TSummaryRow >> | undefined ;
16551650 onRowChange: (column : CalculatedColumn <TRow , TSummaryRow >, rowIdx : number , newRow : TRow ) => void ;
16561651 rowClass: Maybe <(row : TRow , rowIdx : number ) => Maybe <string >>;
1652+ isTreeGrid: boolean ;
16571653 // ... and event handlers
16581654}
16591655```
@@ -1662,7 +1658,7 @@ interface RenderRowProps<TRow, TSummaryRow = unknown> {
16621658
16631659Props passed to the cell renderer when using ` renderers.renderCell ` .
16641660
1665- Shares a base type with row render props (DOM props and cell event handlers) but only includes cell-specific fields like ` column ` , ` row ` , ` rowIdx ` , ` colSpan ` , and selection state.
1661+ Shares a base type with row render props (DOM props and cell event handlers) but only includes cell-specific fields like ` column ` , ` row ` , ` rowIdx ` , ` colSpan ` , and position state.
16661662
16671663#### ` Renderers<TRow, TSummaryRow> `
16681664
@@ -1684,37 +1680,25 @@ Arguments passed to cell mouse event handlers.
16841680
16851681``` tsx
16861682interface CellMouseArgs <TRow , TSummaryRow = unknown > {
1683+ /** The column object of the cell. */
16871684 column: CalculatedColumn <TRow , TSummaryRow >;
1685+ /** The row object of the cell. */
16881686 row: TRow ;
1687+ /** The row index of the cell. */
16891688 rowIdx: number ;
1690- selectCell: (enableEditor ? : boolean ) => void ;
1689+ /** Function to manually focus the cell. Pass `true` to immediately start editing. */
1690+ setActivePosition: (enableEditor ? : boolean ) => void ;
16911691}
16921692```
16931693
1694- ##### ` column: CalculatedColumn<TRow, TSummaryRow> `
1695-
1696- The column object of the cell.
1697-
1698- ##### ` row: TRow `
1699-
1700- The row object of the cell.
1701-
1702- ##### ` rowIdx: number `
1703-
1704- The row index of the cell.
1705-
1706- ##### ` selectCell: (enableEditor?: boolean) => void `
1707-
1708- Function to manually select the cell. Pass ` true ` to immediately start editing.
1709-
17101694** Example:**
17111695
17121696``` tsx
17131697import type { CellMouseArgs , CellMouseEvent } from ' react-data-grid' ;
17141698
17151699function onCellClick(args : CellMouseArgs <Row >, event : CellMouseEvent ) {
17161700 console .log (' Clicked cell at row' , args .rowIdx , ' column' , args .column .key );
1717- args .selectCell (true ); // Select and start editing
1701+ args .setActivePosition (true ); // Focus and start editing
17181702}
17191703```
17201704
@@ -1747,7 +1731,7 @@ import type { CellMouseArgs, CellMouseEvent } from 'react-data-grid';
17471731
17481732function onCellClick(args : CellMouseArgs <Row >, event : CellMouseEvent ) {
17491733 if (args .column .key === ' actions' ) {
1750- event .preventGridDefault (); // Prevent cell selection
1734+ event .preventGridDefault (); // Prevent cell focus
17511735 }
17521736}
17531737```
@@ -1774,17 +1758,17 @@ type CellClipboardEvent = React.ClipboardEvent<HTMLDivElement>;
17741758
17751759#### ` CellKeyDownArgs<TRow, TSummaryRow> `
17761760
1777- Arguments passed to the ` onCellKeyDown ` handler. The shape differs based on whether the cell is in SELECT or EDIT mode.
1761+ Arguments passed to the ` onCellKeyDown ` handler. The shape differs based on whether the cell is in ACTIVE or EDIT mode.
17781762
1779- ** SELECT mode:**
1763+ ** ACTIVE mode:**
17801764
17811765``` tsx
1782- interface SelectCellKeyDownArgs <TRow , TSummaryRow = unknown > {
1783- mode: ' SELECT ' ;
1766+ interface ActiveCellKeyDownArgs <TRow , TSummaryRow = unknown > {
1767+ mode: ' ACTIVE ' ;
17841768 column: CalculatedColumn <TRow , TSummaryRow > | undefined ;
1785- row: TRow ;
1769+ row: TRow | undefined ;
17861770 rowIdx: number ;
1787- selectCell : (position : Position , options ? : SelectCellOptions ) => void ;
1771+ setActivePosition : (position : Position , options ? : SetActivePositionOptions ) => void ;
17881772}
17891773```
17901774
@@ -1797,7 +1781,7 @@ interface EditCellKeyDownArgs<TRow, TSummaryRow = unknown> {
17971781 row: TRow ;
17981782 rowIdx: number ;
17991783 navigate: () => void ;
1800- onClose: (commitChanges ? : boolean , shouldFocusCell ? : boolean ) => void ;
1784+ onClose: (commitChanges ? : boolean , shouldFocus ? : boolean ) => void ;
18011785}
18021786```
18031787
@@ -1814,15 +1798,24 @@ function onCellKeyDown(args: CellKeyDownArgs<Row>, event: CellKeyboardEvent) {
18141798}
18151799```
18161800
1817- #### ` CellSelectArgs <TRow, TSummaryRow>`
1801+ #### ` PositionChangeArgs <TRow, TSummaryRow>`
18181802
1819- Arguments passed to ` onSelectedCellChange ` .
1803+ Arguments passed to ` onActivePositionChange ` .
18201804
18211805``` tsx
1822- interface CellSelectArgs <TRow , TSummaryRow = unknown > {
1806+ interface PositionChangeArgs <TRow , TSummaryRow = unknown > {
1807+ /** row index of the active position */
18231808 rowIdx: number ;
1809+ /**
1810+ * row object of the active position,
1811+ * undefined if the active position is on a header or summary row
1812+ */
18241813 row: TRow | undefined ;
1825- column: CalculatedColumn <TRow , TSummaryRow >;
1814+ /**
1815+ * column object of the active position,
1816+ * undefined if the active position is a row instead of a cell
1817+ */
1818+ column: CalculatedColumn <TRow , TSummaryRow > | undefined ;
18261819}
18271820```
18281821
@@ -1854,9 +1847,9 @@ Arguments passed to the `colSpan` function.
18541847
18551848``` tsx
18561849type ColSpanArgs <TRow , TSummaryRow > =
1857- | { type: ' HEADER' }
1858- | { type: ' ROW' ; row: TRow }
1859- | { type: ' SUMMARY' ; row: TSummaryRow };
1850+ | { readonly type: ' HEADER' }
1851+ | { readonly type: ' ROW' ; readonly row: TRow }
1852+ | { readonly type: ' SUMMARY' ; readonly row: TSummaryRow };
18601853```
18611854
18621855** Example:**
@@ -1989,14 +1982,14 @@ interface Position {
19891982}
19901983```
19911984
1992- #### ` SelectCellOptions `
1985+ #### ` SetActivePositionOptions `
19931986
1994- Options for programmatically selecting a cell .
1987+ Options for programmatically updating the grid's active position .
19951988
19961989``` tsx
1997- interface SelectCellOptions {
1990+ interface SetActivePositionOptions {
19981991 enableEditor? : Maybe <boolean >;
1999- shouldFocusCell ? : Maybe <boolean >;
1992+ shouldFocus ? : Maybe <boolean >;
20001993}
20011994```
20021995
@@ -2054,8 +2047,8 @@ Handle type assigned to a grid's `ref` for programmatic grid control.
20542047``` tsx
20552048interface DataGridHandle {
20562049 element: HTMLDivElement | null ;
2057- scrollToCell: (position : Partial < Position > ) => void ;
2058- selectCell : (position : Position , options ? : SelectCellOptions ) => void ;
2050+ scrollToCell: (position : PartialPosition ) => void ;
2051+ setActivePosition : (position : Position , options ? : SetActivePositionOptions ) => void ;
20592052}
20602053```
20612054
0 commit comments