LearnNewsExamplesServices
Frontmatter
id8985
titlerefactor: Add getRow helper to GridBody
stateClosed
labels
airefactoring
assigneestobiu
createdAtFeb 4, 2026, 2:28 PM
updatedAtFeb 4, 2026, 2:33 PM
githubUrlhttps://github.com/neomjs/neo/issues/8985
authortobiu
commentsCount1
parentIssue8964
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 4, 2026, 2:33 PM

refactor: Add getRow helper to GridBody

Closed v12.0.0 airefactoring
tobiu
tobiu commented on Feb 4, 2026, 2:28 PM

Objective: Refactor the logic for retrieving a Neo.grid.Row component instance given a data record into a reusable helper method getRow(record) within Neo.grid.Body.

Current State: Neo.grid.column.AnimatedChange manually calculates the row index and accesses the body's item array using modulo arithmetic:

row = body.items[body.store.indexOf(record) % body.items.length]

Proposed Change:

  1. Implement Neo.grid.Body.getRow(record):
    • Find the record's index in the store.
    • Verify the index is within the currently mountedRows range.
    • Return the corresponding Row component from the pool.
  2. Update Consumers: Refactor Neo.grid.column.AnimatedChange to use this new method.

Benefits:

  • Encapsulation: Hides row pooling implementation details (modulo logic) from columns.
  • Safety: Ensures the returned row is actually currently mounted and assigned to the target record.
  • Reusability: Useful for other column types or controllers needing row access.
tobiu added the ai label on Feb 4, 2026, 2:28 PM
tobiu added the refactoring label on Feb 4, 2026, 2:28 PM
tobiu referenced in commit 04c2bc6 - "refactor: Add getRow helper to GridBody (#8985)" on Feb 4, 2026, 2:31 PM
tobiu
tobiu Feb 4, 2026, 2:32 PM

Input from Gemini 3 Pro:

✦ I have implemented the getRow helper and refactored AnimatedChange to use it.

Changes:

  1. src/grid/Body.mjs: Added getRow(record). This method encapsulates the logic for finding a row component:
    • It retrieves the record index.
    • It checks if the index is within the mountedRows range (safety check).
    • It returns the recycled row component using modulo arithmetic on the pool size.
  2. src/grid/column/AnimatedChange.mjs: Updated to use body.getRow(record) instead of manual calculation. This is cleaner and safer.

I have pushed the changes to the feature branch.

tobiu assigned to @tobiu on Feb 4, 2026, 2:33 PM
tobiu added parent issue #8964 on Feb 4, 2026, 2:33 PM
tobiu closed this issue on Feb 4, 2026, 2:33 PM