From ef2407832202e5451751e26459e6bdcdbd152122 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sat, 21 May 2022 16:04:06 +0200 Subject: fix: close Ackee tooltip on button click The tooltip was closing and reopening on click because of a conflict between the button event and the hook useClickOutside. By checking that the event target is not the button, the tooltip is now closing as expected. --- src/components/atoms/buttons/button.tsx | 35 ++++++++++++++-------- src/components/molecules/buttons/help-button.tsx | 12 +++++--- .../molecules/forms/select-with-tooltip.tsx | 11 +++++-- 3 files changed, 39 insertions(+), 19 deletions(-) (limited to 'src/components') diff --git a/src/components/atoms/buttons/button.tsx b/src/components/atoms/buttons/button.tsx index a6eef8b..9776687 100644 --- a/src/components/atoms/buttons/button.tsx +++ b/src/components/atoms/buttons/button.tsx @@ -1,4 +1,9 @@ -import { FC, MouseEventHandler, ReactNode } from 'react'; +import { + forwardRef, + ForwardRefRenderFunction, + MouseEventHandler, + ReactNode, +} from 'react'; import styles from './buttons.module.scss'; export type ButtonProps = { @@ -41,23 +46,27 @@ export type ButtonProps = { * * Use a button as call to action. */ -const Button: FC = ({ - className = '', - children, - disabled = false, - kind = 'secondary', - shape = 'rectangle', - type = 'button', - ...props -}) => { +const Button: ForwardRefRenderFunction = ( + { + className = '', + children, + disabled = false, + kind = 'secondary', + shape = 'rectangle', + type = 'button', + ...props + }, + ref +) => { const kindClass = styles[`btn--${kind}`]; const shapeClass = styles[`btn--${shape}`]; return (