Skip to content

fix(grid): treat a record key of 0 as a valid row id in selection models (#21133) - #21134

Merged
tobiu merged 1 commit into
neomjs:devfrom
alhinawi:fix/grid-selection-zero-key
Nov 16, 2026
Merged

tobiu merged 1 commit into
neomjs:devfrom
alhinawi:fix/grid-selection-zero-key

Conversation

@alhinawi

Copy link
Copy Markdown
Contributor

Resolves #21133

Under useInternalId: false, a record keyed 0 is now treated as a real row id across the grid selection models: the row paints as selected in every body, getRowRecord(0) resolves the record, and ArrowUp/ArrowDown can leave and land on the row. Six truthiness checks (!id, !recordIds, selectedRows[0] || fallback, if (recordId)) in src/selection/grid became == null / ?? / != null, matching the codebase idiom; behavior for null and undefined ids is unchanged.

Evidence: the ticket's probe showed getRowRecord(0) → null and no painted selection for key 0 → the fix flips exactly the six guards the ticket names. Residual: the ticket's last AC (a view.selectedRecords spec once #21132 merges) is unverifiable until that PR lands; #21132 is still open at this writing. Residual-Owner: #21132.

AC Evidence

| AC-1 (selectRow(0) paints in every body) | CI-covered: test/playwright/unit/grid/ViewOwnedSelectionModel.spec.mjs › "selectRow(0) paints the row keyed 0 in every body, and getRowRecord resolves only real ids" |
| AC-2 (getRowRecord(0) resolves; null/undefined still null) | CI-covered: same spec, getRowRecord assertions |
| AC-3 (ArrowDown/ArrowUp off and onto key 0, 0 not first, RowModel + CellRowModel) | CI-covered: specs "RowModel: ArrowDown moves off the row keyed 0…" and "CellRowModel: ArrowDown moves off the row keyed 0…" (key map puts 0 on the second row) |
| AC-4 (new specs fail on dev before the fix) | outside-CI: ran the three new specs with the src/selection/grid changes stashed → 3 failed; with the fix → 24/24 pass. Command: npx playwright test -c test/playwright/playwright.config.unit.mjs test/playwright/unit/grid/ViewOwnedSelectionModel.spec.mjs |
| AC-5 (selectedRecords spec if #21132 merged) | Not applicable yet: #21132 is open; noted as residual above |

Deltas from ticket

None substantive. The ticket's table-family out-of-scope note stands; no src/selection/table/ changes.

Test Evidence

Outside-CI run receipts (Node 24.11.1, Linux):

  • Fix stashed (dev head 2404340): 3 failed — the three new specs, confirming each fails before the fix.
  • Fix applied: full ViewOwnedSelectionModel.spec.mjs → 24 passed (5.8s) (21 pre-existing + 3 new), so no regression in the View-owned selection suite.

agent-preflight: not hosted here; change class: bug fix, bounded to the ticket.

Post-Merge Validation

Authored by @alhinawi (LLM-assisted; model and version withheld per operator policy, reasoning: default, Instinct agent).

Copilot AI balanced review requested due to automatic review settings November 16, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

At least one reviewer session failed, leaving the review evidence incomplete.

No open issues 🎉

What changed in this PR

Fixes grid selection for records keyed 0 when useInternalId: false, supporting correct row painting, record lookup, and keyboard navigation.

Changes:

  • Replaces six truthiness checks with null-aware checks while preserving handling of null and undefined.
  • Adds three regression tests covering selection painting across bodies, record lookup, and navigation with key 0 away from the first row.
File Description
test/​playwright/​unit/​grid/​ViewOwnedSelectionModel.spec.mjs Adds regression coverage for records keyed 0.
src/​selection/​grid/​RowModel.mjs Allows row navigation from and onto key 0.
src/​selection/​grid/​CellRowModel.mjs Applies the same navigation fix to cell-row selection.
src/​selection/​grid/​BaseModel.mjs Allows key 0 in row repainting and record lookup.

Review effort: Balanced

@neo-gpt-emmy neo-gpt-emmy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Micro-Review

Opening: Thank you, @alhinawi, for putting key zero on the second row in the regression. That placement catches a fallback to the first row that an apparently passing navigation test could otherwise hide. Grid selection · Neo introduction · Run the Engine · Help-wanted issues

Class: contained — six existing checks distinguish an absent row key from the numeric primary key zero. The existing selection and painting paths own the change.

Verdict: Approved

Glance: At 73fb728be5ae13e8d61fa7c783d552b5fe5d2b9a I traced the scalar key through updateRows, the store lookup, and both keyboard models. The assertions cover all three body regions, leaving zero and landing on it again, plus the null and undefined controls. The diff is confined to the six sites in #21133 and their regression. The author records all three failures with the fix removed. Hosted CI is green. #21132 is still open, so the ticket’s conditional selectedRecords check does not apply to this revision.

Findings: None.

  • Origin Session ID: 289da399-da26-4b13-ad71-dae9311704bf
  • PR body attribution checked.

🪡 Emmy · GPT-6 Astra · Codex

@neo-gpt-emmy

Copy link
Copy Markdown
Contributor

@alhinawi, #21132 has now merged. The production files merge cleanly. GitHub reports one conflict because both PRs appended independent test.describe blocks at the same line in ViewOwnedSelectionModel.spec.mjs.

I integrated 459371e353 into your 73fb728be5 locally and verified the resulting file is exactly the new dev file followed by your complete zero-key block. All 27 tests in that file passed. The contributor branch is still at your existing revision. Please merge current neomjs/neo:dev into your branch, retain both complete blocks, and push the merge. Your original commits and production changes can stay as submitted.

Emmy · @neo-gpt-emmy

@neo-gpt-emmy

Copy link
Copy Markdown
Contributor

@alhinawi, the tested merge commit is now available from the Engine repository. It has your current head as its first parent and keeps both complete test blocks. All 27 tests in that file passed, and I checked that the result also merges cleanly with today’s dev at 42db8e724e.

From your fix/grid-selection-zero-key branch, you can adopt it directly:

git fetch https://github.com/neomjs/neo.git refs/heads/codex/21133-integrate-test-append
git merge --ff-only FETCH_HEAD
git push origin fix/grid-selection-zero-key

The last command assumes origin is your fork. If the fast-forward reports you have additional local commits, keep them and reply here so we can reconcile them. Once the PR updates, I’ll check CI and the approval again.

— Emmy

…els (neomjs#21133)

Six truthiness checks in src/selection/grid read a row id of 0 as
'no id': BaseModel#updateRows and #getRowRecord, and onNavKeyRow in
RowModel and CellRowModel. Under useInternalId: false with a record
keyed 0, the row never painted as selected, getRowRecord(0) returned
null, and arrow navigation could neither leave nor land on the row.

Read a row id as missing only when it is null or undefined, matching
the codebase's == null idiom. Adds three specs covering the ticket's
acceptance criteria; each fails on dev before this change.
@neo-gpt-emmy
neo-gpt-emmy force-pushed the fix/grid-selection-zero-key branch from 73fb728 to d7fce80 Compare November 16, 2026 17:06
@neo-gpt-emmy

Copy link
Copy Markdown
Contributor

@alhinawi, I rebased your PR onto current dev at 537cfaf768. My earlier comment put the integration work on you. That belongs to us as maintainers, and it’s done. Your fix and original commit authorship are preserved on d7fce809a4.

The only conflict was the adjacent test suites. I verified byte-for-byte that the resolved file contains dev’s complete tests followed by all three of your zero-key cases. All 27 tests in the file passed. GitHub now reports the PR is conflict-free. I’m following the hosted checks and will renew the review on this head. No contributor action is needed.

— Emmy

@neo-gpt-emmy neo-gpt-emmy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Micro-Delta Review

Context: The prior semantic approval covered zero-key selection. This review verifies the maintainer rebase.

State Vector

  • Target SHA: d7fce809a4c5349126babb0b8d763746a5deb5fd
  • Origin Session ID: 289da399-da26-4b13-ad71-dae9311704bf
  • Current reviewDecision: APPROVED
  • Semantic Status: APPROVED
  • CI Status: GREEN. All seven required checks passed, including the aggregate for eleven browser shards.
  • Remaining Blocker Class: mechanical-hygiene
  • Measured Discussion Cost: 7,459 bytes across the PR body, comments and reviews before this review.

Micro-Delta Focus

Only defects classified as mechanical-hygiene or metadata-drift are reviewed here.

The contributor's commit now has 537cfaf768 as its sole parent and retains its original author and message. The entire rebased tree matches the independently composed tree. The resolved file contains the base's complete 28,974-byte test file followed by the contributor's complete 2,565-byte test addition. All 27 affected tests and 22 neighboring grid-selection cases passed locally. The zero-key tests still cover record lookup and navigation in both directions.

Verdict

  • APPROVED
  • COMMENTED CLOSURE
  • MAINTAINER POLISH FAST PATH APPLIED — rebase and adjacent test additions resolved. Approved on this head.

🪡 Emmy · @neo-gpt-emmy

@tobiu
tobiu merged commit 2bd4474 into neomjs:dev Nov 16, 2026
33 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Merged. Thank you: this is your first merged pull request in Neo.mjs.

Standing: Contributor (1 merged). 4 more reach Returning Contributor.

Your badge, if you would like to show it, is written by a scheduled run that has not counted this merge yet. From then on it is at https://neomjs.com/badges/alhinawi-68702059/ in three forms to choose from, and the card's line shows it:
<a href="https://neomjs.com/badges/alhinawi-68702059/"><img src="https://neomjs.com/badges/alhinawi-68702059/card.svg" alt="Neo.mjs contributor"></a>

Next, if you want one: #19145 and #20696 are open and unclaimed; a comment on either claims it. The full list has more if both are taken by then.

See it run: the engine you changed runs live in the browser: https://neomjs.com/examples

A star helps others find the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grid row selection treats a record keyed 0 as no record

4 participants