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

fix(clerk-react): Fix forceRedirectUrl and fallbackRedirectUrl when passed to button components #3508

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

BRKalow
Copy link
Member

@BRKalow BRKalow commented Jun 3, 2024

Description

When passing forceRedirectUrl and fallbackRedirectUrl to SignInButton and SignUpButton, the props were getting renamed and subsequently ignored by the flow when opening in a modal. I fixed the property names and added a few test cases to cover the behavior.

Note that the non-modal flow wasn't broken as it expects the prefixed props (signInForceRedirectUrl, signInFallbackRedierctUrl).

Writing the tests also uncovered a bug with our modal implementation where the entire modal DOM tree was wrapped in an element that had aria-hidden, which I fixed.

Checklist

  • npm test runs as expected.
  • npm run 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 Jun 3, 2024

🦋 Changeset detected

Latest commit: df2f087

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

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

Comment on lines +15 to +17
const opts: SignInProps = {
forceRedirectUrl,
fallbackRedirectUrl,
Copy link
Member Author

Choose a reason for hiding this comment

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

The modal mode relies on the non-prefixed props, adding the type here revealed the issue.

Comment on lines +27 to +28
signInFallbackRedirectUrl: fallbackRedirectUrl,
signInForceRedirectUrl: forceRedirectUrl,
Copy link
Member Author

Choose a reason for hiding this comment

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

when calling the redirect methods, the prefixed props are necessary. Added here.

Comment on lines +33 to +35
if (child && typeof child === 'object' && 'props' in child) {
await safeExecute(child.props.onClick)(e);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Some auto-fix of a lint rule caused a type error, so I tweaked the logic a bit here as a result.

Choose a reason for hiding this comment

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

Interesting.

@@ -50,15 +50,13 @@ export const Modal = withFloatingTree((props: ModalProps) => {
>
<ModalContext.Provider value={modalCtx}>
<Flex
aria-hidden
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we want this, as it removes the entire modal from the accessibility tree.

Choose a reason for hiding this comment

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

Definitely not 😅

@BRKalow BRKalow requested a review from a team June 3, 2024 22:20
Comment on lines +66 to 67
fallbackRedirectUrl: url,
signUpFallbackRedirectUrl: url,
Copy link
Member

Choose a reason for hiding this comment

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

@BRKalow why do we need both ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't technically. The modal requires the unprefixed but the redirect method requires the prefixed. I can adjust the implementation to not pass both.

Copy link
Member

Choose a reason for hiding this comment

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

I believe types only require the prefixed variant, so we are good

@LekoArts LekoArts enabled auto-merge (squash) June 4, 2024 09:04
@LekoArts LekoArts merged commit 35a0015 into main Jun 4, 2024
11 checks passed
@LekoArts LekoArts deleted the brk.fix/sign-in-up-redirect-props branch June 4, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants