Skip to content

Commit

Permalink
- Restore support for zIndex and appendTo props to Popover and Tooltip.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattias800 committed Sep 11, 2024
1 parent 25701f0 commit 1d403e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/tooltip/src/components/popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface PopoverProps {
variant?: PopoverVariant;
theme?: PopoverTheme;
renderTrigger: (props: Record<string, unknown>) => ReactNode;
appendTo?: HTMLElement | null | React.MutableRefObject<HTMLElement | null>;
zIndex?: number;
}

const ARROW_WIDTH = 12;
Expand All @@ -67,6 +69,8 @@ export const Popover: React.FC<PopoverProps> = ({
hideArrow,
renderTrigger,
disablePadding,
appendTo,
zIndex,
}) => {
const [isOpen, setIsOpen] = useState(false);

Expand Down Expand Up @@ -118,11 +122,11 @@ export const Popover: React.FC<PopoverProps> = ({
{renderTrigger({ ref: refs.setReference, ...getReferenceProps() })}

{isMounted && (
<FloatingPortal>
<FloatingPortal root={appendTo}>
<FloatingFocusManager context={context} modal={false}>
<div
ref={refs.setFloating}
style={floatingStyles}
style={{ zIndex, ...floatingStyles }}
{...getFloatingProps}
>
<div
Expand Down
8 changes: 6 additions & 2 deletions packages/tooltip/src/components/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface TooltipProps extends PropsWithChildren {
label: string;
variant?: TooltipVariant;
maxWidth?: CSSProperties["maxWidth"];
appendTo?: HTMLElement | null | React.MutableRefObject<HTMLElement | null>;
zIndex?: number;
}

type TooltipVariant = "info" | "warning" | "error";
Expand All @@ -52,6 +54,8 @@ export const Tooltip: React.FC<TooltipProps> = ({
label,
variant,
maxWidth = "500px",
appendTo,
zIndex,
}) => {
const [isOpen, setIsOpen] = useState(false);

Expand Down Expand Up @@ -87,8 +91,8 @@ export const Tooltip: React.FC<TooltipProps> = ({
</div>

{isMounted && (
<FloatingPortal>
<div ref={refs.setFloating} style={floatingStyles}>
<FloatingPortal root={appendTo}>
<div ref={refs.setFloating} style={{ zIndex, ...floatingStyles }}>
<div
style={{ maxWidth, ...styles }}
className={cx(
Expand Down

0 comments on commit 1d403e5

Please sign in to comment.