-
Notifications
You must be signed in to change notification settings - Fork 431
feat(clerk-js): Add reset method to Sign[In|Up] resource
#7606
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
alexcarpenter
wants to merge
10
commits into
main
Choose a base branch
from
alexcarpenter/add-sign-up-reset-method
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.
+332
−20
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3dc0055
feat(clerk-js): Add `reset` method to SignUp resource
alexcarpenter df89c90
set to null to avoid api call
alexcarpenter 931c1e4
fix linting
alexcarpenter 921e646
add changeset
alexcarpenter 7f67200
Update stateProxy.ts
alexcarpenter 7225024
Update stateProxy.ts
alexcarpenter 8fd50e2
feat: Add reset method to signInFuture resource
alexcarpenter ce84163
Merge branch 'main' into alexcarpenter/add-sign-up-reset-method
jacekradko b1695c6
PR feedback
alexcarpenter 66fc05d
feat(clerk-js): Improve reset mechanism (#7662)
dstaley 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
Some comments aren't visible on the classic Files Changed page.
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,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/shared': patch | ||
| --- | ||
|
|
||
| Add `reset` method to the sign-in resource. |
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,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/shared': patch | ||
| --- | ||
|
|
||
| Add `reset` method to the new signUp resource. |
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.
🧩 Analysis chain
🏁 Script executed:
Repository: clerk/javascript
Length of output: 2887
🏁 Script executed:
Repository: clerk/javascript
Length of output: 2223
🏁 Script executed:
Repository: clerk/javascript
Length of output: 1532
🏁 Script executed:
Repository: clerk/javascript
Length of output: 50482
🏁 Script executed:
Repository: clerk/javascript
Length of output: 4761
🏁 Script executed:
Repository: clerk/javascript
Length of output: 872
🏁 Script executed:
Repository: clerk/javascript
Length of output: 242
🏁 Script executed:
Repository: clerk/javascript
Length of output: 1948
🏁 Script executed:
Repository: clerk/javascript
Length of output: 1747
🏁 Script executed:
Repository: clerk/javascript
Length of output: 966
Emit
resource:updateevent to update resource signal after resetresetSignIn()/resetSignUp()only emitresource:error, which updates the error signal but not the resource signal. ThesignInResourceSignal/signUpResourceSignalnever reflects the new reset instance because State'sonResourceUpdatedhandler is never called.When
resource:updateis emitted aftercanBeDiscardedis set to true (by the Future.reset() call), theshouldIgnoreNullUpdatecheck will pass and the signal will be properly updated.Proposed fix
resetSignIn(): void { this.signIn = new SignIn(null); - // Cast needed because this.signIn is typed as SignInResource (interface), not SignIn (class extending BaseResource) - eventBus.emit('resource:error', { resource: this.signIn as SignIn, error: null }); + eventBus.emit('resource:update', { resource: this.signIn as SignIn }); + eventBus.emit('resource:error', { resource: this.signIn as SignIn, error: null }); } resetSignUp(): void { this.signUp = new SignUp(null); - // Cast needed because this.signUp is typed as SignUpResource (interface), not SignUp (class extending BaseResource) - eventBus.emit('resource:error', { resource: this.signUp as SignUp, error: null }); + eventBus.emit('resource:update', { resource: this.signUp as SignUp }); + eventBus.emit('resource:error', { resource: this.signUp as SignUp, error: null }); }📝 Committable suggestion
🤖 Prompt for AI Agents