Skip to content

Commit

Permalink
feat(clerk-js,types): Add option to disable portaling within UserButt…
Browse files Browse the repository at this point in the history
…on and OrgSwitcher components
  • Loading branch information
alexcarpenter committed Jul 29, 2024
1 parent a6620ae commit 1b565f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { useId } from 'react';

import { AcceptedInvitationsProvider, withCoreUserGuard } from '../../contexts';
import { AcceptedInvitationsProvider, useOrganizationSwitcherContext, withCoreUserGuard } from '../../contexts';
import { Flow } from '../../customizables';
import { Popover, withCardStateProvider, withFloatingTree } from '../../elements';
import { usePopover } from '../../hooks';
import { OrganizationSwitcherPopover } from './OrganizationSwitcherPopover';
import { OrganizationSwitcherTrigger } from './OrganizationSwitcherTrigger';

const _OrganizationSwitcher = withFloatingTree(() => {
const { defaultOpen, portal } = useOrganizationSwitcherContext();
const { floating, reference, styles, toggle, isOpen, nodeId, context } = usePopover({
defaultOpen,
placement: 'bottom-start',
offset: 8,
});
Expand All @@ -32,6 +34,7 @@ const _OrganizationSwitcher = withFloatingTree(() => {
nodeId={nodeId}
context={context}
isOpen={isOpen}
portal={portal}
>
<OrganizationSwitcherPopover
id={switcherButtonMenuId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserButtonPopover } from './UserButtonPopover';
import { UserButtonTrigger } from './UserButtonTrigger';

const _UserButton = withFloatingTree(() => {
const { defaultOpen } = useUserButtonContext();
const { defaultOpen, portal } = useUserButtonContext();
const { floating, reference, styles, toggle, isOpen, nodeId, context } = usePopover({
defaultOpen,
placement: 'bottom-end',
Expand All @@ -33,6 +33,7 @@ const _UserButton = withFloatingTree(() => {
nodeId={nodeId}
context={context}
isOpen={isOpen}
portal={portal}
>
<UserButtonPopover
id={userButtonMenuId}
Expand Down
10 changes: 10 additions & 0 deletions packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
portal?: boolean;
/**
* Full URL or path to navigate after sign out is complete
* @deprecated Configure `afterSignOutUrl` as a global configuration, either in <ClerkProvider/> or in await Clerk.load()
Expand Down Expand Up @@ -949,6 +954,11 @@ export type OrganizationSwitcherProps = CreateOrganizationMode &
* Controls the default state of the OrganizationSwitcher
*/
defaultOpen?: boolean;
/**
* By default, the popover will be rendered outside of the app root and into the body.
* @default true
*/
portal?: boolean;
/**
* By default, users can switch between organization and their personal account.
* This option controls whether OrganizationSwitcher will include the user's personal account
Expand Down

0 comments on commit 1b565f8

Please sign in to comment.