From 741d2c8bdd7f2a7752cdc4466c1f572f44d72aaa Mon Sep 17 00:00:00 2001 From: Ryan Price <7935599+ryprice@users.noreply.github.com> Date: Thu, 18 Jan 2024 09:40:50 -0500 Subject: [PATCH] Handle outside click for story creator url popper --- ts/components/TextStoryCreator.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ts/components/TextStoryCreator.tsx b/ts/components/TextStoryCreator.tsx index 948c97b27d..a320c84d76 100644 --- a/ts/components/TextStoryCreator.tsx +++ b/ts/components/TextStoryCreator.tsx @@ -301,6 +301,29 @@ export function TextStoryCreator({ ); }, [isColorPickerShowing, colorPickerPopperRef, colorPickerPopperButtonRef]); + useEffect(() => { + if (!isLinkPreviewInputShowing) { + return noop; + } + return handleOutsideClick( + () => { + setIsLinkPreviewInputShowing(false); + return true; + }, + { + containerElements: [ + linkPreviewInputPopperRef, + linkPreviewInputPopperButtonRef, + ], + name: 'TextStoryCreator.linkPreviewInput', + } + ); + }, [ + isLinkPreviewInputShowing, + linkPreviewInputPopperRef, + linkPreviewInputPopperButtonRef, + ]); + const sliderColorNumber = getRGBANumber(sliderValue); let textForegroundColor = sliderColorNumber;