Skip to content
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

feat(clerk-js): Redirect to current page when within modal and no redirect url is provided #4762

Conversation

alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Dec 11, 2024

Description

For our <SignInButton /> and <SignUpButton /> usage when mode="modal" and no redirect url is provided, fallback to redirecting to the current page vs being redirected to /.

Resolves SDKI-616

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 8888795

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 11:49pm

@alexcarpenter alexcarpenter changed the title feat(clerk-js): Redirect to current page when routing is virtual and no redirect url is provided feat(clerk-js): Redirect to current page when within modal and no redirect url is provided Dec 11, 2024
@alexcarpenter alexcarpenter marked this pull request as ready for review December 11, 2024 23:26
* When we're in modal mode and no redirect_url is provided, we want to redirect to the current page after sign-in or sign-up.
*/
export const determineRedirectUrlFromMode = ({ mode, url, clerk }: { mode: Mode; url: string; clerk: Clerk }) => {
return mode === 'modal' && url === '/' ? window.location.href : clerk.buildUrlWithAuth(url);
Copy link
Member

Choose a reason for hiding this comment

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

what if afterSignInUrl was set explicitly to / ?

Maybe this logic should exists inside new RedirectUrls()

Copy link
Member Author

@alexcarpenter alexcarpenter Dec 12, 2024

Choose a reason for hiding this comment

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

Yeah thats is a good call, opened a separate PR with that approach here #4768

@alexcarpenter
Copy link
Member Author

closing in favor of #4768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants