-
Notifications
You must be signed in to change notification settings - Fork 431
feat(core): Split setActive into selectSession and selectOrganization #7646
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
Open
jacekradko
wants to merge
5
commits into
main
Choose a base branch
from
jacek/user-4041-split-setactive-to-select-methods
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
abe85ee
feat(core): Split setActive into selectSession and selectOrganization
jacekradko d37f6f1
feat(core): Remove setActive from hook return types (clean break)
jacekradko 95e325f
chore: add changeset for setActive split
jacekradko 1fbbd70
feat(core): Remove setActive from public API, migrate remaining usages
jacekradko a6880dd
docs: Update changeset for setActive removal
jacekradko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| '@clerk/clerk-js': major | ||
| '@clerk/shared': major | ||
| '@clerk/react': major | ||
| '@clerk/nextjs': major | ||
| '@clerk/vue': major | ||
| '@clerk/expo': major | ||
| '@clerk/ui': major | ||
| '@clerk/testing': major | ||
| --- | ||
|
|
||
| Replace `setActive` with purpose-specific methods: `selectSession` and `selectOrganization` | ||
|
|
||
| ## Breaking Changes | ||
|
|
||
| ### `setActive` Removed from Public API | ||
|
|
||
| The `setActive` method has been removed from the Clerk object and all hooks. Use the new purpose-specific methods instead: | ||
|
|
||
| - `clerk.selectSession(session, options?)` - For session selection | ||
| - `clerk.selectOrganization(organization, options?)` - For organization selection | ||
|
|
||
| ### Hook Return Types | ||
|
|
||
| The following hooks no longer return `setActive`: | ||
|
|
||
| - `useSignIn()` - now returns `selectSession` instead of `setActive` | ||
| - `useSignUp()` - now returns `selectSession` instead of `setActive` | ||
| - `useSessionList()` - now returns `selectSession` instead of `setActive` | ||
| - `useOrganizationList()` - now returns `selectOrganization` instead of `setActive` | ||
|
|
||
| ### Migration | ||
|
|
||
| **Before:** | ||
| ```tsx | ||
| const { setActive } = useSignIn(); | ||
| await setActive({ session: createdSessionId }); | ||
|
|
||
| const { setActive } = useOrganizationList(); | ||
| await setActive({ organization: org }); | ||
| ``` | ||
|
|
||
| **After:** | ||
| ```tsx | ||
| const { selectSession } = useSignIn(); | ||
| await selectSession(createdSessionId); | ||
|
|
||
| const { selectOrganization } = useOrganizationList(); | ||
| await selectOrganization(org); | ||
| ``` | ||
|
|
||
| ### New Methods on Clerk Object | ||
|
|
||
| Two new methods are available on the Clerk object: | ||
|
|
||
| - `clerk.selectSession(session, options?)` - For session selection (sign-in, sign-up, multi-session switching) | ||
| - `clerk.selectOrganization(organization, options?)` - For organization selection (org switching, personal workspace) | ||
|
|
||
| ### Options | ||
|
|
||
| Both methods accept an options object: | ||
|
|
||
| ```tsx | ||
| // selectSession options | ||
| await selectSession(session, { | ||
| redirectUrl?: string; | ||
| navigate?: ({ session }) => void | Promise<void>; | ||
| }); | ||
|
|
||
| // selectOrganization options | ||
| await selectOrganization(organization, { | ||
| redirectUrl?: string; | ||
| navigate?: ({ session, organization }) => void | Promise<void>; | ||
| }); | ||
| ``` | ||
|
|
||
| ### Expo Hooks | ||
|
|
||
| The `StartGoogleAuthenticationFlowReturnType` and `StartAppleAuthenticationFlowReturnType` types now return `selectSession` instead of `setActive`. | ||
|
|
||
| ### Internal Window Hooks (Next.js) | ||
|
|
||
| The internal window hooks have been renamed: | ||
| - `__internal_onBeforeSetActive` → `__internal_onBeforeSelectSession` | ||
| - `__internal_onAfterSetActive` → `__internal_onAfterSelectSession` | ||
|
|
||
| ### Types Removed | ||
|
|
||
| The following types have been removed from the public API: | ||
| - `SetActive` | ||
| - `SetActiveParams` | ||
| - `SetActiveNavigate` (use `SelectSessionNavigate` instead) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use the selected organization when invoking
navigate.When
organizationis a string, the callback receivesthis.organization(the current org), not the newly selected one. This can route to the wrong org or personal workspace. Resolve the organization from the session being activated (e.g., viasession.lastActiveOrganizationIdor memberships) before callingnavigate.🛠️ Proposed fix
🤖 Prompt for AI Agents