Skip to content

Extract useSelectCards composable for multi-select dialogs - #1489

Merged
itsalaidbacklife merged 5 commits into
cuttle-cards:mainfrom
seoijin109:feature/1460
Nov 21, 2026
Merged

itsalaidbacklife merged 5 commits into
cuttle-cards:mainfrom
seoijin109:feature/1460

Conversation

@seoijin109

@seoijin109 seoijin109 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Issue number

Relevant issue number

Please check the following

  • Do the tests still pass? (see Run the Tests)
  • Is the code formatted properly? (see Linting (Formatting))
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

This PR covers #1460, except for the shared .is-selected CSS (see the question below).

  • Adds src/composables/useSelectCards.js, which accepts either a number or a ref/computed for count (via toValue), with Vitest unit tests in tests/unit/specs/use-select-cards.spec.js.
  • Multi-select: FourRevealDialog, FourDiscardDialog and DiscardToHandLimitDialog use it with no template name changes.
  • Single-select: ThreeDialog and SevenDoubleJacksDialog use it with count = 1. SevenDoubleJacksDialog is converted to <script setup>, following the same approach as refactor(four-dialog): migrate FourDialog to script setup (#1412) #1477. Both already toggled, so no behaviour change.
  • Legacy FourDialog uses it with count = 2, keeping its special ready rule (one card is enough when only one is in hand).
  • FiveDialog uses it with count = 1. UX change: clicking the selected card again now deselects it. This is in its own commit, so it's easy to drop if you'd rather keep the old behaviour.

Verified locally: npm run lint and npm run test:unit pass, and the 3_threes, 4_fours, 5_fives, 7_sevens/player_sevens and handLimit e2e specs pass.

Not included: the duplicated .is-selected CSS. 4_fours.spec.js asserts on the is-selected class, and GameCard already has its own selected style in a different colour, so moving it into a shared style or a GameCard prop seemed like a design decision worth checking first. Happy to do it here or in a follow-up, whichever you prefer.

RetriggerView in GreptileConfidence Score: 5/5

The changes appear safe to merge based on the code reviewed.

Summary

Extracts shared card selection into useSelectCards and adopts it across seven game dialogs.

  • Multi-card dialogs now share one way to track selected cards.
  • One-card choices now clear when players click them again.

No actionable new issues found. Validation was blocked because eslint is not installed; tests did not run.

Reviews (2) · Last reviewed commit: "Use useSelectCards in FiveDialog (select..." · Reviewed by Greptile

Copilot AI balanced review requested due to automatic review settings November 13, 2026 10:05

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@itsalaidbacklife itsalaidbacklife added dev experience Improvements to the code base that make it easier/better/more enjoyable to contribute to Cuttle version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1) frontend Requires changes to the frontend (vue) client labels Nov 13, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 16:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@seoijin109

Copy link
Copy Markdown
Contributor Author

I've extended this PR to cover the single-select dialogs and the legacy FourDialog as well (see the updated description). The FiveDialog toggle change is in a separate commit in case you'd prefer to leave it out.

@itsalaidbacklife itsalaidbacklife 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.

Nice work; thank you for your contribution!

@itsalaidbacklife
itsalaidbacklife merged commit 1e371c3 into cuttle-cards:main Nov 21, 2026
11 checks passed
@seoijin109
seoijin109 deleted the feature/1460 branch November 21, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev experience Improvements to the code base that make it easier/better/more enjoyable to contribute to Cuttle frontend Requires changes to the frontend (vue) client version-patch An update that warrants a bumping the project's patch version (e.g. 4.0.0 => 4.0.1)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants