From 436550b16748545faf4215386d86a805d7f75550 Mon Sep 17 00:00:00 2001 From: Tal Koren Date: Thu, 18 Jan 2024 17:25:02 +0200 Subject: [PATCH] feat: add tooltip props (#1901) --- src/components/Menu/MenuItem/MenuItem.tsx | 5 ++++- src/components/MenuButton/MenuButton.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Menu/MenuItem/MenuItem.tsx b/src/components/Menu/MenuItem/MenuItem.tsx index dbd73a5f3d..6dd3f6f693 100644 --- a/src/components/Menu/MenuItem/MenuItem.tsx +++ b/src/components/Menu/MenuItem/MenuItem.tsx @@ -5,7 +5,7 @@ import { isFunction } from "lodash-es"; import { ComponentDefaultTestId, getTestId } from "../../../tests/test-ids-utils"; import { DialogPosition } from "../../../constants/positions"; import Text from "../../Text/Text"; -import Tooltip from "../../../components/Tooltip/Tooltip"; +import Tooltip, { TooltipProps } from "../../../components/Tooltip/Tooltip"; import Icon from "../../../components/Icon/Icon"; import DialogContentContainer from "../../../components/DialogContentContainer/DialogContentContainer"; import useMergeRef from "../../../hooks/useMergeRef"; @@ -48,6 +48,7 @@ export interface MenuItemProps extends VibeComponentProps { tooltipContent?: string; tooltipPosition?: TooltipPosition; tooltipShowDelay?: number; + tooltipProps?: TooltipProps; onMouseLeave?: (event: React.MouseEvent) => void; onMouseEnter?: (event: React.MouseEvent) => void; /** @@ -108,6 +109,7 @@ const MenuItem: VibeComponent & { tooltipContent, tooltipPosition = MenuItem.tooltipPositions.RIGHT, tooltipShowDelay = 300, + tooltipProps, isInitialSelectedState, onMouseEnter, onMouseLeave, @@ -334,6 +336,7 @@ const MenuItem: VibeComponent & { showDelay={tooltipShowDelay} // Tooltip should be on a whole MenuItem, but it's a breaking change - should be fixed in the next major and then this can be removed moveBy={icon && tooltipPosition === Tooltip.positions.LEFT ? { main: 30 } : undefined} + {...tooltipProps} >
{title} diff --git a/src/components/MenuButton/MenuButton.tsx b/src/components/MenuButton/MenuButton.tsx index 384e6c553a..2e28e53312 100644 --- a/src/components/MenuButton/MenuButton.tsx +++ b/src/components/MenuButton/MenuButton.tsx @@ -4,7 +4,7 @@ import { camelCase } from "lodash-es"; import { isForwardRef } from "react-is"; import Dialog, { DialogEvent } from "../Dialog/Dialog"; import DialogContentContainer from "../DialogContentContainer/DialogContentContainer"; -import Tooltip from "../Tooltip/Tooltip"; +import Tooltip, { TooltipProps } from "../Tooltip/Tooltip"; import { backwardCompatibilityForProperties } from "../../helpers/backwardCompatibilityForProperties"; import useMergeRef from "../../hooks/useMergeRef"; import { BUTTON_ICON_SIZE } from "../Button/ButtonConstants"; @@ -101,6 +101,7 @@ interface MenuButtonProps extends VibeComponentProps { * Tooltip Element Wrapper ClassName */ tooltipReferenceClassName?: string; + tooltipProps?: TooltipProps; /** * When the MenuButton is hidden hide the dialog and tooltip as well */ @@ -154,6 +155,7 @@ const MenuButton: VibeComponent & { disabled = false, text, tooltipContent, + tooltipProps, // Backward compatibility for props naming disabledReason, tooltipTriggers = [MenuButton.hideTriggers.MOUSE_LEAVE], @@ -309,6 +311,7 @@ const MenuButton: VibeComponent & { hideTrigger={tooltipTriggers} referenceWrapperClassName={tooltipReferenceClassName} hideWhenReferenceHidden={hideWhenReferenceHidden} + {...tooltipProps} >