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,types): Add option to disable portaling within UserButton and OrgSwitcher components #3837

Conversation

alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Jul 29, 2024

Description

Allow disabling portal usage within both <UserButton > and <OrganizationSwitcher /> components to allow folks to make use of these components within dialog or sheet contexts.

<UserButton portal={false} />
<OrganizationSwitcher portal={false} />
Screen.Recording.2024-07-29.at.1.29.28.PM.mov

https://linear.app/clerk/issue/SDKI-518/expose-portal-prop-to-userbutton-and-organizationswitcher-components

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 29, 2024

🦋 Changeset detected

Latest commit: d80fd2b

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

const { floating, reference, styles, toggle, isOpen, nodeId, context } = usePopover({
defaultOpen,
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix defaultOpen usage.

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 1.0.5-snapshot.vd80fd2b
@clerk/backend 1.5.0-snapshot.vd80fd2b
@clerk/chrome-extension 1.1.8-snapshot.vd80fd2b
@clerk/clerk-js 5.10.3-snapshot.vd80fd2b
@clerk/elements 0.10.8-snapshot.vd80fd2b
@clerk/clerk-expo 2.0.1-snapshot.vd80fd2b
@clerk/express 0.0.22-snapshot.vd80fd2b
@clerk/fastify 1.0.24-snapshot.vd80fd2b
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.5.3-snapshot.vd80fd2b
@clerk/nextjs 5.2.9-snapshot.vd80fd2b
@clerk/clerk-react 5.2.11-snapshot.vd80fd2b
@clerk/remix 4.2.8-snapshot.vd80fd2b
@clerk/clerk-sdk-node 5.0.21-snapshot.vd80fd2b
@clerk/shared 2.4.2-snapshot.vd80fd2b
@clerk/tanstack-start 0.1.12-snapshot.vd80fd2b
@clerk/testing 1.2.4-snapshot.vd80fd2b
@clerk/themes 2.1.15-snapshot.vd80fd2b
@clerk/types 4.9.2-snapshot.vd80fd2b

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

gatsby-plugin-clerk

npm i [email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/clerk-sdk-node

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@alexcarpenter alexcarpenter requested a review from a team July 29, 2024 17:30
Comment on lines +2 to +3
"@clerk/clerk-js": patch
"@clerk/types": patch
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"@clerk/clerk-js": patch
"@clerk/types": patch
"@clerk/clerk-js": minor
"@clerk/types": minor

We're adding new functionality, so we should use a minor version.

@@ -894,6 +894,11 @@ export type UserButtonProps = UserButtonProfileMode & {
* Controls the default state of the UserButton
*/
defaultOpen?: boolean;
/**
* By default, the popover will be rendered outside of the app root and into the body.
* @default true
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing where this is being defaulted to true. Is that somewhere outside this PR? I tried to track it down, but our Context setup seems a bit complex 😵‍💫

Copy link
Member

Choose a reason for hiding this comment

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

I had the same question, the existing code defines it so it's hard to see it in the PR. It is defined here

Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

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

LGTM, just a recommendation about naming

* By default, the popover will be rendered outside of the app root and into the body.
* @default true
*/
portal?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

🙃 maybe skipPortal ?

@@ -894,6 +894,11 @@ export type UserButtonProps = UserButtonProfileMode & {
* Controls the default state of the UserButton
*/
defaultOpen?: boolean;
/**
* By default, the popover will be rendered outside of the app root and into the body.
* @default true
Copy link
Member

Choose a reason for hiding this comment

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

I had the same question, the existing code defines it so it's hard to see it in the PR. It is defined here

@alexcarpenter alexcarpenter marked this pull request as draft July 29, 2024 18:26
@alexcarpenter
Copy link
Member Author

Closing for now, as we'd need to account for modals as well, which is a bit bigger of a lift that needs more consideration.

@alexcarpenter alexcarpenter deleted the alexcarpenter/sdki-518-expose-portal-prop-to-userbutton-and-organizationswitcher branch August 2, 2024 17:44
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.

4 participants