Skip to content

Prevent ActionList crash when selected prop is used without selectionVariant #6235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025

Conversation

liuliu-dev
Copy link
Contributor

@liuliu-dev liuliu-dev commented Jun 25, 2025

Closes 5066

Changelog

New

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 18:22
@liuliu-dev liuliu-dev requested a review from a team as a code owner June 25, 2025 18:22
@liuliu-dev liuliu-dev requested a review from jonrohan June 25, 2025 18:22
Copy link

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: 50662d4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the runtime error thrown when an ActionList item is marked selected without a selectionVariant by issuing a development-only warning instead. It also updates the test to expect console.warn and adds a changeset for the patch release.

  • Swapped hard throw with a dev-only warning
  • Adjusted the test to spy on console.warn rather than expecting an exception
  • Added a .changeset entry for versioning

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/ActionList/Selection.tsx Replace thrown error with a warning util call and return null
packages/react/src/ActionList/ActionList.test.tsx Update test to spy on console.warn and verify warning message
.changeset/true-lines-find.md Add patch-level changeset for this fix

)
} else {
return null
warning(true, 'For Item to be selected, ActionList or ActionList.Group should have a selectionVariant defined.')
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

The warning util triggers a warning only when its first argument is falsy. Passing true here means the warning will never fire. You should pass false (e.g., warning(false, ...)) to actually emit the warning in development.

Suggested change
warning(true, 'For Item to be selected, ActionList or ActionList.Group should have a selectionVariant defined.')
warning(false, 'For Item to be selected, ActionList or ActionList.Group should have a selectionVariant defined.')

Copilot uses AI. Check for mistakes.

Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jun 25, 2025
Copy link
Contributor

github-actions bot commented Jun 25, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 92.51 KB (+0.05% 🔺)
packages/react/dist/browser.umd.js 92.56 KB (-0.05% 🔽)

Copy link
Member

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Let's run a integration test before we merge.

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jun 25, 2025
@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/386657

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Jun 26, 2025
@liuliu-dev liuliu-dev added this pull request to the merge queue Jun 26, 2025
Merged via the queue into main with commit 5446544 Jun 26, 2025
35 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/actionlist-selection-error-handling branch June 26, 2025 19:03
@primer primer bot mentioned this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants