Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Button's tooltipText needs to show on hover #1817

Merged
merged 5 commits into from
Jul 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/odyssey-react-mui/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import { Button as MuiButton } from "@mui/material";
import type { ButtonProps as MuiButtonProps } from "@mui/material";
import { memo, ReactElement, useContext, useMemo } from "react";
import { memo, ReactElement, useCallback, useContext } from "react";

import { Icon } from "./Icon";
import { MuiPropsContext } from "./MuiPropsContext";
Expand Down Expand Up @@ -48,8 +48,8 @@ const Button = ({
}: ButtonProps) => {
const muiProps = useContext(MuiPropsContext);

const button = useMemo(
() => (
const renderButton = useCallback(
(muiProps) => (
<MuiButton
{...muiProps}
disabled={isDisabled}
Expand All @@ -69,7 +69,6 @@ const Button = ({
id,
isDisabled,
isFullWidth,
muiProps,
onClick,
size,
startIcon,
Expand All @@ -82,10 +81,11 @@ const Button = ({
<>
{tooltipText && (
<Tooltip ariaType="description" placement="top" text={tooltipText}>
{button}
<MuiPropsContext.Consumer>{renderButton}</MuiPropsContext.Consumer>
</Tooltip>
)}
{!tooltipText && button}

{!tooltipText && renderButton(muiProps)}
</>
);
};
Expand Down