Skip to content

Commit

Permalink
feat: add tooltip props (#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
talkor authored Jan 18, 2024
1 parent 9c1bb47 commit 436550b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/Menu/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
/**
Expand Down Expand Up @@ -108,6 +109,7 @@ const MenuItem: VibeComponent<MenuItemProps> & {
tooltipContent,
tooltipPosition = MenuItem.tooltipPositions.RIGHT,
tooltipShowDelay = 300,
tooltipProps,
isInitialSelectedState,
onMouseEnter,
onMouseLeave,
Expand Down Expand Up @@ -334,6 +336,7 @@ const MenuItem: VibeComponent<MenuItemProps> & {
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}
>
<div ref={titleRef} className={styles.title}>
{title}
Expand Down
5 changes: 4 additions & 1 deletion src/components/MenuButton/MenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -154,6 +155,7 @@ const MenuButton: VibeComponent<MenuButtonProps> & {
disabled = false,
text,
tooltipContent,
tooltipProps,
// Backward compatibility for props naming
disabledReason,
tooltipTriggers = [MenuButton.hideTriggers.MOUSE_LEAVE],
Expand Down Expand Up @@ -309,6 +311,7 @@ const MenuButton: VibeComponent<MenuButtonProps> & {
hideTrigger={tooltipTriggers}
referenceWrapperClassName={tooltipReferenceClassName}
hideWhenReferenceHidden={hideWhenReferenceHidden}
{...tooltipProps}
>
<Dialog
wrapperClassName={dialogClassName}
Expand Down

0 comments on commit 436550b

Please sign in to comment.