Skip to content

Commit

Permalink
17450 popover with auto align is breaking (#17455)
Browse files Browse the repository at this point in the history
* fix: popover with autoalign is breaking

* fix: removed commented code

* fix: using the ref in toggleTipContent

* fix: added display name for toggletipComponent

* fix: removed commnets

---------

Co-authored-by: Guilherme Datilio Ribeiro <[email protected]>
  • Loading branch information
preetibansalui and guidari authored Sep 30, 2024
1 parent 00fe911 commit 75001eb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9455,6 +9455,7 @@ Map {
"render": [Function],
},
"ToggletipContent" => Object {
"$$typeof": Symbol(react.forward_ref),
"propTypes": Object {
"children": Object {
"type": "node",
Expand All @@ -9463,6 +9464,7 @@ Map {
"type": "string",
},
},
"render": [Function],
},
"ToggletipLabel" => Object {
"propTypes": Object {
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ export const Popover: PopoverComponent = React.forwardRef(
autoAlign && displayName && ['ToggletipButton'].includes(displayName);
const isAllowedTriggerComponent =
autoAlign &&
displayName &&
!['ToggletipContent', 'PopoverContent'].includes(displayName);

if (
Expand Down
20 changes: 13 additions & 7 deletions packages/react/src/components/Toggletip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,21 @@ interface ToggletipContentProps {
* `children` passed in as a prop inside of `PopoverContent` so that they will
* be rendered inside of the popover for this component.
*/
export function ToggletipContent({
children,
className: customClassName,
}: ToggletipContentProps) {
const ToggletipContent = React.forwardRef<
HTMLDivElement,
ToggletipContentProps
>(function ToggletipContent({ children, className: customClassName }, ref) {
const toggletip = useToggletip();
const prefix = usePrefix();
return (
<PopoverContent className={customClassName} {...toggletip?.contentProps}>
<PopoverContent
className={customClassName}
{...toggletip?.contentProps}
ref={ref}>
<div className={`${prefix}--toggletip-content`}>{children}</div>
</PopoverContent>
);
}

});
ToggletipContent.propTypes = {
/**
* Custom children to be rendered as the content of the label
Expand All @@ -357,6 +359,10 @@ ToggletipContent.propTypes = {
className: PropTypes.string,
};

ToggletipContent.displayName = 'ToggletipContent';

export { ToggletipContent };

interface ToggleTipActionsProps {
children?: ReactNode;
className?: string | undefined;
Expand Down

0 comments on commit 75001eb

Please sign in to comment.