Context:
Following the implementation of internalId (#9070) and subsequent fixes for selection logic, we identified significant technical debt in the src/selection/grid namespace. The current architecture suffers from deep inheritance chains, duplicated logic, and brittle type-checking heuristics.
Problem:
- Deep Inheritance: The chain
CellColumnRowModel -> CellRowModel -> CellModel -> BaseModel forces hybrid models to override logic from ancestors that doesn't fit (e.g., CellRowModel having to manually sync row selection because CellModel ignores it).
- Logic Duplication:
CellColumnModel and CellColumnRowModel duplicate the "Conditional Flush" logic (checking isEqual on selectedColumns) to ensure visual updates.
- Brittle
updateRows: BaseModel.updateRows uses string parsing (includes('__')) to distinguish between Cell IDs and Record IDs. This is fragile and should be polymorphic.
- Column Selection Redundancy: Multiple models manage column selection using copied logic.
Objectives:
- Introduce Mixins: Refactor
RowSelection and ColumnSelection into reusable Mixins. Use composition instead of deep inheritance for hybrid models (e.g., CellModel + RowSelectionMixin).
- Polymorphic Updates: Refactor
updateRows to delegate to a polymorphic updateItem(item) method on the subclass, eliminating the need for isCell checks in the base class.
- Centralize Flush Logic: Move the
selectedColumns change detection and flush logic into a shared location (Mixin or Base).
- Normalize IDs: Ensure consistent handling of
internalId vs recordId across all models.
Scope:
src/selection/grid/BaseModel.mjs
src/selection/grid/RowModel.mjs
src/selection/grid/CellModel.mjs
src/selection/grid/ColumnModel.mjs
src/selection/grid/CellRowModel.mjs
src/selection/grid/CellColumnModel.mjs
src/selection/grid/CellColumnRowModel.mjs
Context: Following the implementation of
internalId(#9070) and subsequent fixes for selection logic, we identified significant technical debt in thesrc/selection/gridnamespace. The current architecture suffers from deep inheritance chains, duplicated logic, and brittle type-checking heuristics.Problem:
CellColumnRowModel -> CellRowModel -> CellModel -> BaseModelforces hybrid models to override logic from ancestors that doesn't fit (e.g.,CellRowModelhaving to manually sync row selection becauseCellModelignores it).CellColumnModelandCellColumnRowModelduplicate the "Conditional Flush" logic (checkingisEqualonselectedColumns) to ensure visual updates.updateRows:BaseModel.updateRowsuses string parsing (includes('__')) to distinguish between Cell IDs and Record IDs. This is fragile and should be polymorphic.Objectives:
RowSelectionandColumnSelectioninto reusable Mixins. Use composition instead of deep inheritance for hybrid models (e.g.,CellModel+RowSelectionMixin).updateRowsto delegate to a polymorphicupdateItem(item)method on the subclass, eliminating the need forisCellchecks in the base class.selectedColumnschange detection and flush logic into a shared location (Mixin or Base).internalIdvsrecordIdacross all models.Scope:
src/selection/grid/BaseModel.mjssrc/selection/grid/RowModel.mjssrc/selection/grid/CellModel.mjssrc/selection/grid/ColumnModel.mjssrc/selection/grid/CellRowModel.mjssrc/selection/grid/CellColumnModel.mjssrc/selection/grid/CellColumnRowModel.mjs