Context
Part of #20667: what an application or a package outside this repository can contribute to the grid. A selection model is such a contribution, and today it can state a cell selection only as one id per cell. Measured on dev 62f75736ba.
The Problem
A model that selects by a rule (the rectangle between two cells, every cell of a store, a band of rows) cannot tell the grid which cells are selected. It has to write one logical cell id per cell into items, and the row then scans that array once for every cell it renders.
Measurement. Neo.selection.grid.CellModel with singleSelect: false, a store of 20,000 records and 20 columns, a row pool of 36 rows (720 cells), in the unit tier. Render is the median of seven forced grid.Body#createViewData(true, true) runs.
ids in items |
Render, window outside the selection |
Render, window at its start |
One updateCells(items) pass |
| 0 |
2.5 ms |
2.3 ms |
0.05 ms |
| 1,000 |
2.7 ms |
2.7 ms |
3.5 ms |
| 10,000 |
6.4 ms |
2.6 ms |
24.8 ms |
| 100,000 |
49.9 ms |
2.6 ms |
269 ms |
| 200,000 |
107.6 ms |
2.6 ms |
603 ms |
A rectangle of 10,000 rows and 20 columns is 200,000 ids: 43 times the render time and 0.6 s for each selection change, where the answer per cell is two comparisons. A handful of selected cells costs nothing measurable, so this is a missing seam, not a slow path a user of the shipped models meets.
The Architectural Reality
Neo.grid.Row#applyRendererOutput paints a cell's selection from two fixed rules: selectionModel.selectedColumns.includes(dataField) (src/grid/Row.mjs:273) and selectedCells.includes(gridBody.getLogicalCellId(record, dataField)) (:303).
selectedCells is Neo.grid.View#selectedCells, the model's items (src/grid/View.mjs:282). The View owns the one model and a row paints the View's projection without holding it (#18626).
- The row class is fixed:
Neo.grid.Body#createRowPool creates module: Row (src/grid/Body.mjs:771).
- Columns already repaint without ids:
Neo.selection.grid.BaseModel#updateColumns walks the rendered rows and their cell nodes (src/selection/grid/BaseModel.mjs:581). Cells have updateCells(logicalIds), one lookup per id and body.
aria-selected on a cell is written at the same places (Row.mjs:305, BaseModel#updateBodyCells).
#20115 guarded the scan for an empty selection; the scan for a non-empty one is unchanged.
- Design authority: n/a — a missing seam; no existing behavior is called wrong.
The Fix
The row asks, through the View, whether a cell is selected.
Neo.selection.grid.BaseModel gains isSelectedCell(record, dataField). The default answers from items in constant time, so the six shipped models paint what they paint today. A model that selects by rule overrides it.
Row#applyRendererOutput uses that answer in place of the scan at :303, reached through the View as selectedCells is today.
BaseModel gains the cell counterpart of updateColumns: one method that re-evaluates the answer over the rendered rows and updates only the rows that changed. A rule change repaints through it, with no id list.
BaseModel gains getCellCls(record, dataField), the classes a model adds to a selected cell, empty by default. A model that draws an outline around its selection needs them.
items is written in place (cloneOnGet: 'none'), so the constant-time lookup has to stay true to it. Where that lookup lives is the implementer's call.
Contract Ledger
| Target surface |
Source of authority |
Proposed behavior |
Fallback / edge |
Docs |
Evidence |
Neo.selection.grid.BaseModel#isSelectedCell(record, dataField) (new) |
this ticket |
true when the model holds the cell selected; the default is membership in items in constant time |
a model that selects no cells answers false |
JSDoc with @summary, naming when to override |
unit arms per shipped model: painted cells unchanged |
Neo.selection.grid.BaseModel#getCellCls(record, dataField) (new) |
this ticket |
extra classes for a selected cell |
[] by default |
JSDoc |
unit arm with a rule model |
Neo.selection.grid.BaseModel#updateRenderedCells(silent) (new), the rendered-cell repaint |
BaseModel#updateColumns (BaseModel.mjs:581) as precedent |
re-evaluates both answers over rendered rows; updates only rows that changed |
no rendered row: nothing happens |
JSDoc |
unit arm: a rule change repaints with empty items |
Neo.grid.Row#applyRendererOutput (src/grid/Row.mjs:158) |
:273, :303 |
reads the model's answer; no array scan per cell |
no selection model: no class |
none |
the measurement repeated |
Neo.selection.grid.BaseModel#applyCellSelection(cell, record, dataField) (new) |
this ticket |
writes the model's answer onto one cell vdom node: the selected class, aria-selected and the classes of getCellCls; returns whether the node changed. The row and the granular repaints both call it |
withdraws only the classes it put on the node |
JSDoc |
unit: the rule model's arms; RowCellIdMigration (the row calls it once per living cell) |
Neo.selection.grid.BaseModel#isSelected(id) (override) |
Neo.selection.Model#isSelected |
the same answer in constant time |
follows items through select, deselect, deselectAll, an assignment and a length change |
JSDoc |
unit arm: the answer follows items |
Neo.grid.View#cellSelectionModel (new getter) |
View#rowSelectionModel as precedent |
the one model when it selects cells, else null; the row reads it |
null under a row or column model, and under none |
JSDoc |
unit arm: a row or column model is not asked |
Neo.grid.View#selectedCells (src/grid/View.mjs:282) |
#18626 |
unchanged for its other reader, grid.plugin.CellEditing (src/grid/plugin/CellEditing.mjs:211) |
none |
none |
existing specs |
Decision Record impact: none.
Acceptance Criteria
Out of Scope
- Any shipped model that selects by rule. This ticket delivers the seam and a test model.
- Keyboard, pointer and accessibility behavior of any model.
- The column rule at
Row.mjs:273. It moves behind the same answer only if that makes the diff smaller.
Avoided Traps
- Materializing the rule into ids. The table above.
- A configurable row class. Every package would subclass
Row to change one predicate.
- A model read from the body.
#18626 moved the model to the View; the row keeps reading the View's projection.
Related
#20667 (parent) · #20672 (the value walk a selection reads through).
Live latest-open + closed sweep: checked the latest 20 open issues and closed searches (selection model cells rule, selectedCells, range selection grid, cell selection performance; the bodies of #20115 and #18626 read) at 2026-11-10T03:02Z; no equivalent or prior exclusion found. Backlog: 21 open (green band).
A2A in-flight claim sweep: the last 30 mailbox rows to 03:01Z carry no claim on this scope.
MC sweep: "grid row scans selectedCells includes for every rendered cell, many selected cells slow render", 5 results from February 2026 on granular row repaints (#9014), none a prior decision on a per-cell answer.
Own-assignment sweep: 1 open (#20667, the parent), none overlapping.
Structure map: N/A, no file is placed outside the existing test/playwright/unit/grid/ and src/selection/grid/ folders.
Origin Session ID: fe737fdd-2c32-4a15-bc7d-df3f8da67694
Retrieval Hint: "grid selection model per-cell answer isSelectedCell rule rectangle Row applyRendererOutput scan"
Context
Part of #20667: what an application or a package outside this repository can contribute to the grid. A selection model is such a contribution, and today it can state a cell selection only as one id per cell. Measured on
dev62f75736ba.The Problem
A model that selects by a rule (the rectangle between two cells, every cell of a store, a band of rows) cannot tell the grid which cells are selected. It has to write one logical cell id per cell into
items, and the row then scans that array once for every cell it renders.Measurement.
Neo.selection.grid.CellModelwithsingleSelect: false, a store of 20,000 records and 20 columns, a row pool of 36 rows (720 cells), in the unit tier. Render is the median of seven forcedgrid.Body#createViewData(true, true)runs.itemsupdateCells(items)passA rectangle of 10,000 rows and 20 columns is 200,000 ids: 43 times the render time and 0.6 s for each selection change, where the answer per cell is two comparisons. A handful of selected cells costs nothing measurable, so this is a missing seam, not a slow path a user of the shipped models meets.
The Architectural Reality
Neo.grid.Row#applyRendererOutputpaints a cell's selection from two fixed rules:selectionModel.selectedColumns.includes(dataField)(src/grid/Row.mjs:273) andselectedCells.includes(gridBody.getLogicalCellId(record, dataField))(:303).selectedCellsisNeo.grid.View#selectedCells, the model'sitems(src/grid/View.mjs:282). The View owns the one model and a row paints the View's projection without holding it (#18626).Neo.grid.Body#createRowPoolcreatesmodule: Row(src/grid/Body.mjs:771).Neo.selection.grid.BaseModel#updateColumnswalks the rendered rows and their cell nodes (src/selection/grid/BaseModel.mjs:581). Cells haveupdateCells(logicalIds), one lookup per id and body.aria-selectedon a cell is written at the same places (Row.mjs:305,BaseModel#updateBodyCells).#20115guarded the scan for an empty selection; the scan for a non-empty one is unchanged.The Fix
The row asks, through the View, whether a cell is selected.
Neo.selection.grid.BaseModelgainsisSelectedCell(record, dataField). The default answers fromitemsin constant time, so the six shipped models paint what they paint today. A model that selects by rule overrides it.Row#applyRendererOutputuses that answer in place of the scan at:303, reached through the View asselectedCellsis today.BaseModelgains the cell counterpart ofupdateColumns: one method that re-evaluates the answer over the rendered rows and updates only the rows that changed. A rule change repaints through it, with no id list.BaseModelgainsgetCellCls(record, dataField), the classes a model adds to a selected cell, empty by default. A model that draws an outline around its selection needs them.itemsis written in place (cloneOnGet: 'none'), so the constant-time lookup has to stay true to it. Where that lookup lives is the implementer's call.Contract Ledger
Neo.selection.grid.BaseModel#isSelectedCell(record, dataField)(new)itemsin constant time@summary, naming when to overrideNeo.selection.grid.BaseModel#getCellCls(record, dataField)(new)[]by defaultNeo.selection.grid.BaseModel#updateRenderedCells(silent)(new), the rendered-cell repaintBaseModel#updateColumns(BaseModel.mjs:581) as precedentitemsNeo.grid.Row#applyRendererOutput(src/grid/Row.mjs:158):273,:303Neo.selection.grid.BaseModel#applyCellSelection(cell, record, dataField)(new)aria-selectedand the classes ofgetCellCls; returns whether the node changed. The row and the granular repaints both call itRowCellIdMigration(the row calls it once per living cell)Neo.selection.grid.BaseModel#isSelected(id)(override)Neo.selection.Model#isSelecteditemsthroughselect,deselect,deselectAll, an assignment and a length changeitemsNeo.grid.View#cellSelectionModel(new getter)View#rowSelectionModelas precedentnull; the row reads itnullunder a row or column model, and under noneNeo.grid.View#selectedCells(src/grid/View.mjs:282)#18626grid.plugin.CellEditing(src/grid/plugin/CellEditing.mjs:211)Decision Record impact: none.
Acceptance Criteria
ColumnSelection,ViewOwnedSelectionModel,SelectionModelStateIsolation,RowModelKeypressClick.RowCellIdMigrationkeeps every arm but one: the arm that pinned the row's own scan of an id array pins the row asking the View's cell model once per living cell.itemsempty. The cells inside carry the selected class andaria-selectedon first render, after the rule changes, and on rows that enter the pool by scrolling.Row#applyRendererOutputscans no array per cell for cell selection. The pull request body repeats the table above; the render with 200,000 selected ids lies within the run-to-run spread of the render with none.getCellClsreach the cell node and leave it when the model stops returning them.Out of Scope
Row.mjs:273. It moves behind the same answer only if that makes the diff smaller.Avoided Traps
Rowto change one predicate.#18626moved the model to the View; the row keeps reading the View's projection.Related
#20667 (parent) · #20672 (the value walk a selection reads through).
Live latest-open + closed sweep: checked the latest 20 open issues and closed searches (selection model cells rule, selectedCells, range selection grid, cell selection performance; the bodies of
#20115and#18626read) at 2026-11-10T03:02Z; no equivalent or prior exclusion found. Backlog: 21 open (green band). A2A in-flight claim sweep: the last 30 mailbox rows to 03:01Z carry no claim on this scope. MC sweep: "grid row scans selectedCells includes for every rendered cell, many selected cells slow render", 5 results from February 2026 on granular row repaints (#9014), none a prior decision on a per-cell answer. Own-assignment sweep: 1 open (#20667, the parent), none overlapping. Structure map: N/A, no file is placed outside the existingtest/playwright/unit/grid/andsrc/selection/grid/folders.Origin Session ID: fe737fdd-2c32-4a15-bc7d-df3f8da67694
Retrieval Hint: "grid selection model per-cell answer isSelectedCell rule rectangle Row applyRendererOutput scan"