-
Notifications
You must be signed in to change notification settings - Fork 283
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
Conversation
🦋 Changeset detectedLatest commit: df2f087 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 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 |
const opts: SignInProps = { | ||
forceRedirectUrl, | ||
fallbackRedirectUrl, |
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.
The modal mode relies on the non-prefixed props, adding the type here revealed the issue.
signInFallbackRedirectUrl: fallbackRedirectUrl, | ||
signInForceRedirectUrl: forceRedirectUrl, |
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.
when calling the redirect methods, the prefixed props are necessary. Added here.
if (child && typeof child === 'object' && 'props' in child) { | ||
await safeExecute(child.props.onClick)(e); | ||
} |
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.
Some auto-fix of a lint rule caused a type error, so I tweaked the logic a bit here as a result.
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.
Interesting.
@@ -50,15 +50,13 @@ export const Modal = withFloatingTree((props: ModalProps) => { | |||
> | |||
<ModalContext.Provider value={modalCtx}> | |||
<Flex | |||
aria-hidden |
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.
I don't think we want this, as it removes the entire modal from the accessibility tree.
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.
Definitely not 😅
fallbackRedirectUrl: url, | ||
signUpFallbackRedirectUrl: url, |
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.
@BRKalow why do we need both ?
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.
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.
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.
I believe types only require the prefixed variant, so we are good
Description
When passing
forceRedirectUrl
andfallbackRedirectUrl
toSignInButton
andSignUpButton
, 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.Type of change