From 9696767018b8103d34f87d736e0e5418201b215c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 27 Apr 2023 21:45:04 +0200 Subject: [PATCH] Fix drawer not closing when url change --- site/source/design-system/drawer/Drawer.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/site/source/design-system/drawer/Drawer.tsx b/site/source/design-system/drawer/Drawer.tsx index 7cbb0adb8..e1303608e 100644 --- a/site/source/design-system/drawer/Drawer.tsx +++ b/site/source/design-system/drawer/Drawer.tsx @@ -2,6 +2,7 @@ import FocusTrap from 'focus-trap-react' import { ReactNode, useCallback, useEffect, useRef, useState } from 'react' import ReactDOM from 'react-dom' import { Trans } from 'react-i18next' +import { useLocation } from 'react-router-dom' import styled, { css } from 'styled-components' import { useOnClickOutside } from '@/hooks/useOnClickOutside' @@ -92,6 +93,12 @@ export const Drawer = ({ closeDrawer() }) + const location = useLocation() + + useEffect(() => { + closeDrawer() + }, [closeDrawer, location]) + return ( <> {trigger({