From d609569a8216c60108a2d286b9f0bccb458fcce2 Mon Sep 17 00:00:00 2001 From: Pedro Carreno <34664891+Pkcarreno@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:28:48 -0400 Subject: [PATCH] fix: shared link refresh on time --- .../editor/components/header/sharing-menu.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/features/editor/components/header/sharing-menu.tsx b/src/features/editor/components/header/sharing-menu.tsx index 5f11f63..8fd026b 100644 --- a/src/features/editor/components/header/sharing-menu.tsx +++ b/src/features/editor/components/header/sharing-menu.tsx @@ -40,14 +40,24 @@ export const SharingMenu = () => { } }; - useEffect(() => { + const handleTooltipTriggerClick = () => { + prepareSharedUrl(); + }; + + const prepareSharedUrl = () => { const url = new URL(location.href); + const searchParams = new URLSearchParams(location.hash.slice(1)); if (!isWithCode) { searchParams.delete('code'); } url.hash = searchParams.toString(); + setSharedUrl(url.href); + }; + + useEffect(() => { + prepareSharedUrl(); }, [isTooltipOpen, isWithCode]); return ( @@ -56,7 +66,11 @@ export const SharingMenu = () => { -