Skip to content

feat(elements): Complete and Reset Updates - #3343

Merged
LekoArts merged 9 commits into
mainfrom
elements/complete-step
May 14, 2024
Merged

feat(elements): Complete and Reset Updates#3343
LekoArts merged 9 commits into
mainfrom
elements/complete-step

Conversation

@tmilewski

@tmilewski tmilewski commented May 7, 2024

Copy link
Copy Markdown
Member

Description

This PR contains the results of multiple similar PRs. As-such, this PR ensures the following:

  • The sign-up/in fallback prop isn't presented if the user isn't visiting the root (start) route.
  • Upon completion of sign-up/in, we no longer render the Start step.
  • Fixes the Sign In/Sign Up machine not appropriately attaching new form machines, thus breaking the flow when returning to an already completed flow.
  • Stops the STRATEGY.UNREGISTER event from being called on stopped machines.
  • Updates xstate to v5.13.0

Fixes SDK-1745

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:

@tmilewski tmilewski self-assigned this May 7, 2024
@changeset-bot

changeset-bot Bot commented May 7, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1978150

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

This PR includes changesets to release 1 package
Name Type
@clerk/elements 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

@tmilewski
tmilewski force-pushed the elements/complete-step branch 2 times, most recently from 532bd7c to 377ba9e Compare May 7, 2024 19:53
@tmilewski
tmilewski marked this pull request as ready for review May 7, 2024 19:56
@tmilewski
tmilewski requested review from LekoArts and brkalow May 7, 2024 19:56
Base automatically changed from elements/simplify to main May 7, 2024 20:01

// TODO: eventually we'll rely on the framework SDK to specify its host router, but for now we'll default to Next.js
const router = useNextRouter();
const isRootPath = path === router.pathname();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is required, on both Sign Up and Sign In, otherwise, in the case of callbacks, the fallback will show regardless.

Comment thread packages/elements/src/react/common/loading.tsx Outdated
Comment thread packages/elements/src/internals/machines/sign-in/router.machine.ts Outdated
@LekoArts
LekoArts marked this pull request as draft May 13, 2024 06:50
@tmilewski
tmilewski force-pushed the elements/complete-step branch from 299e17c to f46886f Compare May 13, 2024 19:00
@tmilewski
tmilewski marked this pull request as ready for review May 13, 2024 19:01
@tmilewski
tmilewski force-pushed the elements/complete-step branch from f46886f to 7e74b27 Compare May 13, 2024 19:03
@tmilewski tmilewski changed the title feat(elements): Add complete step to Sign Up and Sign In. feat(elements): Ensure "complete" stage doesn't render alternate steps May 13, 2024
tmilewski added 2 commits May 13, 2024 17:17
* fix(elements): Follow-on machine initialization [SDK-1746]

* chore(elements): Add changeset

* chore(elements): Remove unnecessary TS comment

* chore(elements): Add line item to changeset
@tmilewski tmilewski changed the title feat(elements): Ensure "complete" stage doesn't render alternate steps feat(elements): Complete and Reset Updates May 13, 2024
}, [clerk, exampleMode, formRef, router]);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [clerk, exampleMode, formRef?.id, !!router]);

@tmilewski tmilewski May 13, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I saw that formRef and router were causing many unnecessary re-renders. I narrowed the checks down here and in sign up to optimize.


return () => {
if (factorCtx) {
if (factorCtx?.getSnapshot().status === 'active') {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ensure we only run this event on an active machine.

@LekoArts
LekoArts enabled auto-merge (squash) May 14, 2024 08:35
@LekoArts
LekoArts merged commit e72ab2b into main May 14, 2024
@LekoArts
LekoArts deleted the elements/complete-step branch May 14, 2024 08:46
@clerk-cookie clerk-cookie mentioned this pull request May 14, 2024
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