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/molecules/buttons/help-button.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/components/molecules/buttons/help-button.tsx') diff --git a/src/components/molecules/buttons/help-button.tsx b/src/components/molecules/buttons/help-button.tsx index f19322f..e351453 100644 --- a/src/components/molecules/buttons/help-button.tsx +++ b/src/components/molecules/buttons/help-button.tsx @@ -1,5 +1,5 @@ import Button, { type ButtonProps } from '@components/atoms/buttons/button'; -import { FC } from 'react'; +import { forwardRef, ForwardRefRenderFunction } from 'react'; import { useIntl } from 'react-intl'; import styles from './help-button.module.scss'; @@ -15,7 +15,10 @@ export type HelpButtonProps = Pick & { * * Render a button with an interrogation mark icon. */ -const HelpButton: FC = ({ className = '', onClick }) => { +const HelpButton: ForwardRefRenderFunction< + HTMLButtonElement, + HelpButtonProps +> = ({ className = '', onClick }, ref) => { const intl = useIntl(); const text = intl.formatMessage({ defaultMessage: 'Help', @@ -25,9 +28,10 @@ const HelpButton: FC = ({ className = '', onClick }) => { return (