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

Feat(tooltip): contentが空のときにtooltipを表示しない #1260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
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
5 changes: 5 additions & 0 deletions .changeset/blue-kangaroos-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wizleap-inc/wiz-ui-react": patch
---

[#1258] feat: tooltip にて、content がなければ Popup が表示されないように修正
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Props = BaseProps & {
isOpen?: boolean;
isDirectionFixed?: boolean;
children: ReactNode;
content: ReactNode;
content?: ReactNode;
expand?: boolean;
};

Expand All @@ -34,6 +34,10 @@ const Tooltip: FC<Props> = ({
const [isHover, setIsHover] = useState(false);
const anchor = useRef<HTMLDivElement | null>(null);

const handleClose = useCallback(() => {
setIsHover(false);
}, []);

return (
<>
<div
Expand All @@ -48,30 +52,32 @@ const Tooltip: FC<Props> = ({
>
{children}
</div>
<WizPopup
anchorElement={anchor}
isOpen={isHover || isOpen}
onClose={useCallback(() => setIsHover(false), [])}
direction={direction}
shadow={false}
animation
gap="xs2"
isDirectionFixed={isDirectionFixed}
>
<div
className={clsx(tooltipPositionStyle[direction], tooltipPopupStyle)}
{content && (
<WizPopup
anchorElement={anchor}
isOpen={isHover || isOpen}
onClose={handleClose}
direction={direction}
shadow={false}
animation
gap="xs2"
isDirectionFixed={isDirectionFixed}
>
<div className={clsx(tooltipContentStyle)}>{content}</div>
<div
className={clsx(
tooltipIconStyle,
tooltipIconDirectionStyle[direction]
)}
className={clsx(tooltipPositionStyle[direction], tooltipPopupStyle)}
>
<WizIChangeHistory />
<div className={clsx(tooltipContentStyle)}>{content}</div>
<div
className={clsx(
tooltipIconStyle,
tooltipIconDirectionStyle[direction]
)}
>
<WizIChangeHistory />
</div>
</div>
</div>
</WizPopup>
</WizPopup>
)}
</>
);
};
Expand Down
Loading