GridCore dataController: fix ESLint errors in the updateItems block - #34754
GridCore dataController: fix ESLint errors in the updateItems block#34754Alyar666 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the GridCore DataController “partial refresh” path (the applyChangesOnly / row-index correction flow) to address ESLint issues while improving type safety and extracting reusable row-change utilities.
Changes:
- Renamed internal extensibility hooks from
_applyChangesOnly/_correctRowIndicestoapplyChangesOnly/correctRowIndicesand updated all overrides. - Refactored
DataController.applyChangesOnlyinto smaller helpers and moved key/index/cell-update logic intoutils/row_changes.ts. - Expanded Jest coverage for the extracted
row_changesutilities and introduced supporting types (RowIndexByKey,ItemChange).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts | Updates the keyboard-navigation extender override to the renamed correctRowIndices hook. |
| packages/devextreme/js/__internal/grids/grid_core/editing/m_editing.ts | Updates the editing extender override to the renamed applyChangesOnly hook. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/row_changes.ts | Extracts and adds helper utilities for row keying, indexing, cell updater propagation, and change conversion. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/tests/row_changes.test.ts | Adds unit tests for the newly extracted row-change helpers. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/types.ts | Adds new helper types (RowIndexByKey, ItemChange) used by the refactored update logic. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts | Refactors the partial-update (“repaint changes only”) refresh path, improves typing, and updates insert-index correction logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dcd8301 to
d70a8e5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/row_changes.ts:80
getDataRowIndexallocates intermediate arrays (slice+filter) every time it runs. This method is called fromchangingHandlerfor each inserted change and can run on large visible-row sets; a simple counted loop avoids allocations and should be measurably cheaper while still satisfyingno-plusplusby using+= 1.
export function getDataRowIndex(rows: ProcessedItem[], visibleRowIndex: number): number {
const previousRows = rows.slice(0, visibleRowIndex);
return previousRows.filter((row) => row?.rowType === 'data' || row?.rowType === 'group').length;
}
| * A store change is indexed by data rows, while an insert index coming from the | ||
| * grid counts every visible row — group rows included. | ||
| */ | ||
| export function getDataRowIndex(rows: ProcessedItem[], visibleRowIndex: number): number { |
There was a problem hiding this comment.
| export function getDataRowIndex(rows: ProcessedItem[], visibleRowIndex: number): number { | |
| export function getDataRowCount(rows: ProcessedItem[], visibleRowIndex: number): number { |
| return changedRows; | ||
| } | ||
|
|
||
| export function convertToUpdateChange(change: DataChange, changedRows: ChangedRows): void { |
There was a problem hiding this comment.
'convert' reads as we passed smth and return converted one, not mutate.
can we avoid mutation here?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/row_changes.ts:80
getDataRowIndexallocates intermediate arrays (slice+filter) on every call. This runs in the dataSourcechanginghandler and can be invoked frequently for large grids, so avoiding allocations here helps prevent unnecessary GC pressure.
export function getDataRowIndex(rows: ProcessedItem[], visibleRowIndex: number): number {
const previousRows = rows.slice(0, visibleRowIndex);
return previousRows.filter((row) => row?.rowType === 'data' || row?.rowType === 'group').length;
}
No description provided.