@codecademy/gamut

72.2.272.2.3-alpha.e0a618.0
dist/Tip/shared/FloatingTip.js
~dist/Tip/shared/FloatingTip.jsModified
+15
Index: package/dist/Tip/shared/FloatingTip.js
===================================================================
--- package/dist/Tip/shared/FloatingTip.js
+++ package/dist/Tip/shared/FloatingTip.js
@@ -10,8 +10,9 @@
 export const FloatingTip = ({
   alignment,
   avatar,
   children,
+  closeOnClick,
   escapeKeyPressHandler,
   inheritDims,
   info,
   isTipHidden,
@@ -100,8 +101,21 @@
   }, [isOpen, isFocused]);
   const isHoverType = type === 'tool' || type === 'preview';
   const isPreviewType = type === 'preview';
   const toolOnlyEventFunc = isHoverType ? e => handleShowHideAction(e) : undefined;
+  const handleClick = useCallback(() => {
+    if (hoverDelayRef.current) {
+      clearTimeout(hoverDelayRef.current);
+      hoverDelayRef.current = undefined;
+    }
+    if (focusDelayRef.current) {
+      clearTimeout(focusDelayRef.current);
+      focusDelayRef.current = undefined;
+    }
+    setIsOpen(false);
+    setIsFocused(false);
+  }, []);
+  const clickHandler = closeOnClick && isHoverType ? handleClick : undefined;
   const contents = isPreviewType ? /*#__PURE__*/_jsx(PreviewTipContents, {
     avatar: avatar,
     info: info,
     loading: loading,
@@ -121,8 +135,9 @@
       height: inheritDims ? 'inherit' : undefined,
       ref: ref,
       width: inheritDims ? 'inherit' : undefined,
       onBlur: toolOnlyEventFunc,
+      onClick: clickHandler,
       onFocus: toolOnlyEventFunc,
       onKeyDown: escapeKeyPressHandler,
       onMouseDown: e => e.preventDefault(),
       onMouseEnter: toolOnlyEventFunc,