Skip to content

Commit

Permalink
Fix/enable custom class in TopNavigation to be passed to PopOver (#2280)
Browse files Browse the repository at this point in the history
* Extend the ProfileMenu props to accept a className to be passed to Popover

* Pass fallbackPlacements as [] to disable PopOver flipping behavior

* Add changeset
  • Loading branch information
tranhoangan22 authored Nov 3, 2023
1 parent a07aeeb commit 2897ec7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-buses-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': minor
---

Inside `TopNavigation`, extended `ProfileMenu`'s props to accept a class name to be passed to the `ProfileMenu`'s `PopOver` component. Passed an empty array for the `fallbackPlacements` prop to the `PopOver` used by `TopNavigation` to disable the flipping behavior.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const baseArgs: TopNavigationProps = {
destructive: true,
},
],
className: 'custom-class-name',
},
links: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ export interface ProfileMenuProps extends ProfileProps {
* Function that is called when opening and closing the ProfileMenu.
*/
onToggle?: (isOpen: boolean) => void;
/**
* className for the Popover component.
*/
className?: string | undefined;
}

export function ProfileMenu({
user,
label,
actions,
onToggle,
className,
}: ProfileMenuProps): JSX.Element {
const [isOpen, setOpen] = useState(false);
const offset = { mainAxis: 8, crossAxis: -16 };
Expand All @@ -110,7 +115,9 @@ export function ProfileMenu({
)}
actions={actions}
placement="bottom-end"
fallbackPlacements={[]}
offset={offset}
className={className}
/>
);
}

1 comment on commit 2897ec7

@vercel
Copy link

@vercel vercel bot commented on 2897ec7 Nov 3, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.