Skip to content

fix(opportunities): selection toggle no longer reorders table rows - #775

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/768-opp-table-reorder
May 28, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/768-opp-table-reorder

Conversation

@cristim

@cristim cristim commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

QA 6.1: toggling a row's checkbox on the Opportunities table reordered visible rows.

Root cause

cellScoreFor() accepted a selectedRecs: ReadonlySet<string> parameter and had a short-circuit that, when any variant in a cell was selected, substituted the selected variant's individual value as the cell's sort key. That individual value differs from the deterministic cell-summary score used for unselected cells, so every checkbox toggle mutated sort scores and triggered a full re-sort.

Example: a cell with 1yr + 3yr variants normally sorted by score 103; selecting the 3yr variant changed the cell's score to 303, jumping the row.

Fix

Removed selectedRecs from cellScoreFor and groupsInSortOrder entirely. Sort order now always derives from the cell-summary path. selectedRecs still flows to row-level rendering (checkboxes, selected CSS class, summary cards) -- behavior there is unchanged.

Files changed

  • frontend/src/recommendations.ts
  • frontend/src/__tests__/recommendations.test.ts

Test plan

  • 311 / 311 tests pass.
  • New test: selecting the 3yr variant of a 1yr+3yr cell must not change that cell's score from 103 to 303.
  • New test: row order byte-identical before and after toggling multiple checkboxes.
  • Manual: pick commitments on the Opportunities table; confirm rows stay put.

Closes #768.

…loses #768)

cellScoreFor() had a short-circuit that swapped a cell's sort key to the
selected variant's individual value when selectedRecs contained any variant
in that cell. Because that individual value (e.g. a single term or upfront)
can differ from the deterministic cell-summary score used for unselected
cells, toggling any checkbox mutated sort scores and re-sorted the table.

Fix: remove selectedRecs from cellScoreFor() and groupsInSortOrder()
entirely. Sort order is now always derived from the cell-summary score
(same path that was already used when nothing was selected). The
selectedRecs set continues to flow into buildVariantRowMarkup for
per-row checked-state rendering and CSS, and into renderRecommendationsSummary
for the summary-card narrowing -- neither of those paths affects sort order.

Regression tests added: one verifying term-sort is selection-independent
(the buggy variant would have changed mixed-cell's score from 103 to 303
when its 3yr variant was selected), and one asserting row order is
byte-identical before and after toggling two checkboxes.
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/low Minor harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/s Hours type/bug Defect labels May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 54 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8385f82-e571-40a4-8a99-8533ab7c6d51

📥 Commits

Reviewing files that changed from the base of the PR and between d986b4d and b1857f4.

📒 Files selected for processing (2)
  • frontend/src/__tests__/recommendations.test.ts
  • frontend/src/recommendations.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/768-opp-table-reorder

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@cristim
cristim merged commit 749bf9a into feat/multicloud-web-frontend May 28, 2026
5 checks passed
@cristim
cristim deleted the fix/768-opp-table-reorder branch June 3, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/many Affects most users priority/p2 Backlog-worthy severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant