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

feat(clerk-js): Support open userProfile and organizationProfile modals to specific navitems #3732

Conversation

EmmanouelaPothitou
Copy link
Contributor

@EmmanouelaPothitou EmmanouelaPothitou commented Jul 16, 2024

Description

Support opening the userProfileModal and organizationProfileModal to specific navigation items through the userButton and organizationSwitcher.

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 Jul 16, 2024

🦋 Changeset detected

Latest commit: e92ffe0

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

This PR includes changesets to release 18 packages
Name Type
@clerk/clerk-js Patch
@clerk/types Patch
@clerk/astro Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/elements Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/shared Patch
@clerk/tanstack-start Patch
@clerk/testing Patch
@clerk/themes 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

@EmmanouelaPothitou EmmanouelaPothitou force-pushed the emmanouela/user-176-support-open-openuserprofile-to-specific-page branch from e5a8015 to 5953bb2 Compare July 17, 2024 10:11
@EmmanouelaPothitou EmmanouelaPothitou changed the title Emmanouela/user 176 support open openuserprofile to specific page feat(clerk-js): support open userProfile and organizationProfile modals to specific nav items Jul 17, 2024
@EmmanouelaPothitou EmmanouelaPothitou changed the title feat(clerk-js): support open userProfile and organizationProfile modals to specific nav items feat(clerk-js):support-open-userProfile-and-organizationProfile-modals-to-specific-navitems Jul 17, 2024
@EmmanouelaPothitou EmmanouelaPothitou changed the title feat(clerk-js):support-open-userProfile-and-organizationProfile-modals-to-specific-navitems feat(clerk-js): Support open userProfile and organizationProfile modals to specific navitems Jul 17, 2024
@EmmanouelaPothitou EmmanouelaPothitou marked this pull request as ready for review July 17, 2024 12:51
packages/clerk-js/src/ui/elements/Navbar.tsx Outdated Show resolved Hide resolved
const to = '/' + router.basePath + router.flowStartPath;
const to = router.indexPath;
Copy link
Member

Choose a reason for hiding this comment

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

Could you briefly, our discoveries and why this is a "safe" change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@anagstef
Copy link
Member

@EmmanouelaPothitou can we have an example code snippet of how this will be used by the users?

@EmmanouelaPothitou
Copy link
Contributor Author

have an example code snippet

@anagstef This function will not be used directly by the user. Instead, it will be utilized by custom menu items, which will be introduced in another PR that Nikos will open in the next days. Therefore, I do not have an example code snippet at this time.

packages/clerk-js/src/ui/Components.tsx Outdated Show resolved Hide resolved
packages/clerk-js/src/ui/Components.tsx Outdated Show resolved Hide resolved
}
openUserProfile({
...opts.userProfileProps,
...(__experimental_startPath && { __experimental_startPath }),
Copy link
Member

Choose a reason for hiding this comment

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

❓Shouldn't we update the types of UserProfileModalProps and OrgProfileModalProps to include __experimental_startPath ?

@EmmanouelaPothitou EmmanouelaPothitou force-pushed the emmanouela/user-176-support-open-openuserprofile-to-specific-page branch from f3b0b4c to a642fce Compare July 24, 2024 14:22
@@ -128,7 +128,7 @@ export const mountComponentRenderer = (clerk: Clerk, environment: EnvironmentRes
void preloadComponent(preloadHint);
}
componentsControlsResolver = import('./lazyModules/common').then(({ createRoot }) => {
createRoot(clerkRoot!).render(
Copy link
Member

Choose a reason for hiding this comment

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

Is this changed by mistake from the linter or it's a conscious change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Linter changed it.

Copy link
Member

Choose a reason for hiding this comment

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

We should revert it then

@octoper
Copy link
Member

octoper commented Jul 25, 2024

!preview

@clerk-cookie
Copy link
Collaborator

clerk-cookie commented Jul 25, 2024

Hey @octoper, your preview is available.

Status Preview Updated (UTC)
🍪 Deployed Visit preview Jul 25, 2024 11:44 AM

Copy link
Member

@octoper octoper left a comment

Choose a reason for hiding this comment

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

💯 Good job @EmmanouelaPothitou!

Copy link
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

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

💯

.changeset/cuddly-spoons-decide.md Outdated Show resolved Hide resolved
@EmmanouelaPothitou EmmanouelaPothitou merged commit b486897 into main Jul 25, 2024
17 checks passed
@EmmanouelaPothitou EmmanouelaPothitou deleted the emmanouela/user-176-support-open-openuserprofile-to-specific-page branch July 25, 2024 12:21
brkalow pushed a commit that referenced this pull request Aug 1, 2024
…ls to specific navitems (#3732)

Co-authored-by: panteliselef <[email protected]>
Co-authored-by: Vaggelis Yfantis <[email protected]>
Co-authored-by: Stefanos Anagnostou <[email protected]>
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.

8 participants