-
Notifications
You must be signed in to change notification settings - Fork 430
feat(*): Rename setActive to setSelected #7645
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
Conversation
…e setActive to setSelected BREAKING CHANGE: The `setActive` method has been renamed to `setSelected` to better reflect its behavior with pending sessions. ## Method Rename - `clerk.setActive()` → `clerk.setSelected()` - Hooks now return `setSelected` instead of `setActive`: - `useSignIn()` - `useSignUp()` - `useSessionList()` - `useOrganizationList()` ## Type Renames - `SetActive` → `SetSelected` - `SetActiveParams` → `SetSelectedParams` - `SetActiveNavigate` → `SetSelectedNavigate` - `SetActiveHook` → `SetSelectedHook` ## Internal Flag Renames - `__internal_setActiveInProgress` → `__internal_setSelectedInProgress` - `__internal_onBeforeSetActive` → `__internal_onBeforeSetSelected` - `__internal_onAfterSetActive` → `__internal_onAfterSetSelected` Includes codemod support for automatic migration.
🦋 Changeset detectedLatest commit: 1c39685 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughRenames public API and related types/identifiers from "Active" to "Selected": 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/clerk-js/src/core/__tests__/clerk.test.ts (1)
2353-2406: Rename window hook stubs to__internal_onBefore/AfterSetSelected.The test still stubs
__internal_onBeforeSetActive/__internal_onAfterSetActive, but core now invokes the*Selectedhooks. This can make theupdateClientassertion fail and leaves the new hooks uncleared between tests. Please rename these stubs and cleanups (and apply the same rename across this file).🛠️ Proposed fix (apply similarly to other occurrences in this file)
- (window as any).__internal_onBeforeSetActive = mockOnBeforeSetActive; - (window as any).__internal_onAfterSetActive = mockOnAfterSetActive; + (window as any).__internal_onBeforeSetSelected = mockOnBeforeSetActive; + (window as any).__internal_onAfterSetSelected = mockOnAfterSetActive; - (window as any).__internal_onBeforeSetActive = null; - (window as any).__internal_onAfterSetActive = null; + (window as any).__internal_onBeforeSetSelected = null; + (window as any).__internal_onAfterSetSelected = null;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/upgrade/src/codemods/transform-remove-deprecated-props.cjs`:
- Around line 456-473: The current unconditional rename of Identifier
'setActive' to 'setSelected' is too broad; restrict it to only bindings created
by Clerk hooks/instances by checking the identifier's binding origin before
renaming. In the root.find(j.Identifier, { name: 'setActive' }) loop, skip
identifiers unless their binding (via path.scope.getBinding(path.node.name))
exists and its declaration/init is a Clerk hook call or Clerk instance (e.g.,
VariableDeclarator where init is a CallExpression that satisfies an
isClerkHookCall helper or an Object/MemberExpression originating from a 'clerk'
object); only then change path.node.name to 'setSelected' and mark
changed/stats. Add or use an isClerkHookCall utility to encapsulate hook
detection so unrelated patterns like useState destructuring are not renamed.
| // Rename setActive identifier (e.g., standalone call or destructured) | ||
| root.find(j.Identifier, { name: 'setActive' }).forEach(path => { | ||
| // Skip if it's part of a member expression property (already handled above) | ||
| if ( | ||
| path.parent && | ||
| (path.parent.node.type === 'MemberExpression' || path.parent.node.type === 'OptionalMemberExpression') && | ||
| path.parent.node.property === path.node | ||
| ) { | ||
| return; | ||
| } | ||
| // Skip if it's part of an import specifier (handled separately) | ||
| if (path.parent && path.parent.node.type === 'ImportSpecifier') { | ||
| return; | ||
| } | ||
| path.node.name = 'setSelected'; | ||
| changed = true; | ||
| stats('setActiveRenamed'); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope the setActive identifier rename to Clerk bindings only.
The current Identifier-wide rename will also rewrite unrelated identifiers (e.g., const [x, setActive] = useState(...)), which is a breaking codemod bug. Please restrict renames to bindings that originate from Clerk hooks or Clerk instances.
🐛 Proposed fix (scope rename to Clerk hook destructuring)
- // Rename setActive identifier (e.g., standalone call or destructured)
- root.find(j.Identifier, { name: 'setActive' }).forEach(path => {
- // Skip if it's part of a member expression property (already handled above)
- if (
- path.parent &&
- (path.parent.node.type === 'MemberExpression' || path.parent.node.type === 'OptionalMemberExpression') &&
- path.parent.node.property === path.node
- ) {
- return;
- }
- // Skip if it's part of an import specifier (handled separately)
- if (path.parent && path.parent.node.type === 'ImportSpecifier') {
- return;
- }
- path.node.name = 'setSelected';
- changed = true;
- stats('setActiveRenamed');
- });
+ // Rename bindings originating from Clerk hook destructuring only
+ root
+ .find(j.VariableDeclarator, { id: { type: 'ObjectPattern' } })
+ .filter(path => isClerkHookCall(path.node.init))
+ .forEach(path => {
+ const hasSetActive = path.node.id.properties?.some(
+ prop => prop.type === 'ObjectProperty' && isPropertyKeyNamed(prop.key, 'setActive'),
+ );
+ if (hasSetActive) {
+ path.scope.rename('setActive', 'setSelected');
+ changed = true;
+ stats('setActiveRenamed');
+ }
+ });If you want, I can draft isClerkHookCall and tests for common cases.
🤖 Prompt for AI Agents
In `@packages/upgrade/src/codemods/transform-remove-deprecated-props.cjs` around
lines 456 - 473, The current unconditional rename of Identifier 'setActive' to
'setSelected' is too broad; restrict it to only bindings created by Clerk
hooks/instances by checking the identifier's binding origin before renaming. In
the root.find(j.Identifier, { name: 'setActive' }) loop, skip identifiers unless
their binding (via path.scope.getBinding(path.node.name)) exists and its
declaration/init is a Clerk hook call or Clerk instance (e.g.,
VariableDeclarator where init is a CallExpression that satisfies an
isClerkHookCall helper or an Object/MemberExpression originating from a 'clerk'
object); only then change path.node.name to 'setSelected' and mark
changed/stats. Add or use an isClerkHookCall utility to encapsulate hook
detection so unrelated patterns like useState destructuring are not renamed.
|
Superseded by #7646 which takes a different approach - splitting |
Summary
setActivemethod tosetSelectedacross the entire monorepoSetActive,SetActiveParams,SetActiveNavigate,SetActiveHook)__internal_setActiveInProgress,__internal_onBeforeSetActive,__internal_onAfterSetActive)This is a breaking change for Core 3 that better reflects the method's behavior with pending sessions.
Changes
Method Rename
clerk.setActive()→clerk.setSelected()setSelectedinstead ofsetActive:useSignIn()useSignUp()useSessionList()useOrganizationList()Type Renames
SetActive→SetSelectedSetActiveParams→SetSelectedParamsSetActiveNavigate→SetSelectedNavigateSetActiveHook→SetSelectedHookInternal Flag Renames
__internal_setActiveInProgress→__internal_setSelectedInProgress__internal_onBeforeSetActive→__internal_onBeforeSetSelected__internal_onAfterSetActive→__internal_onAfterSetSelectedPackages Updated
@clerk/shared@clerk/clerk-js@clerk/react@clerk/nextjs@clerk/vue@clerk/expo@clerk/ui@clerk/testing@clerk/upgradeCodemod
Extended
transform-remove-deprecated-props.cjsto automatically migrate:clerk.setActive(...)→clerk.setSelected(...)const { setActive } = useSignIn()→const { setSelected } = useSignIn()Test plan
Closes USER-4041
Summary by CodeRabbit
Breaking Changes
Documentation
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.