-
Notifications
You must be signed in to change notification settings - Fork 460
feat(clerk-js): Support open userProfile and organizationProfile modals to specific navitems #3732
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
Changes from all commits
ef8ca52
635eb04
b6b1395
5953bb2
c0908fe
076d16e
8da90ff
cb32066
33c13ce
5f1f508
a642fce
691bfef
362dcf8
e92ffe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@clerk/clerk-js": patch | ||
| "@clerk/types": patch | ||
| --- | ||
|
|
||
| Add support for opening the `UserProfileModal` and `OrganizationProfileModal` to specific navigation items through the `UserButton` and `OrganizationSwitcher`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,11 +41,27 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => { | |
| })(); | ||
| }); | ||
| } | ||
|
|
||
| openUserProfile(opts.userProfileProps); | ||
| return opts.actionCompleteCallback?.(); | ||
| }; | ||
|
|
||
| const handleUserProfileActionClicked = (__experimental_startPath?: string) => { | ||
| if (opts.userProfileMode === 'navigation') { | ||
| return navigate(opts.userProfileUrl || '').finally(() => { | ||
| void (async () => { | ||
| await sleep(300); | ||
| opts.actionCompleteCallback?.(); | ||
| })(); | ||
| }); | ||
| } | ||
| openUserProfile({ | ||
| ...opts.userProfileProps, | ||
| ...(__experimental_startPath && { __experimental_startPath }), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓Shouldn't we update the types of UserProfileModalProps and OrgProfileModalProps to include |
||
| }); | ||
|
|
||
| return opts.actionCompleteCallback?.(); | ||
| }; | ||
|
|
||
| const handleSignOutAllClicked = () => { | ||
| return signOut(opts.navigateAfterSignOut); | ||
| }; | ||
|
|
@@ -66,6 +82,7 @@ export const useMultisessionActions = (opts: UseMultisessionActionsParams) => { | |
| return { | ||
| handleSignOutSessionClicked, | ||
| handleManageAccountClicked, | ||
| handleUserProfileActionClicked, | ||
| handleSignOutAllClicked, | ||
| handleSessionClicked, | ||
| handleAddAccountClicked, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,8 @@ import { useRouter } from '../router'; | |
| export const useNavigateToFlowStart = () => { | ||
| const router = useRouter(); | ||
| const navigateToFlowStart = async () => { | ||
| const to = '/' + router.basePath + router.flowStartPath; | ||
| const to = router.indexPath; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you briefly, our discoveries and why this is a "safe" change ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the current modal setup, the first element is associated with the '/' path. Previously, clicking the back button in the modal's sidebar navigation would navigate back to the path constructed by '/' + router.basePath + router.flowStartPath, since the modal always opened with the first element selected. Now, with the ability to open the modal on a specific element, the router.flowStartPath is not necessarily the path for the first element anymore. That's why we should now navigate to router.indexPath instead of the previously used router.flowStartPath. |
||
|
|
||
| if (to !== router.currentPath) { | ||
| return router.navigate(to); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.