From 13b4eee53918297bb0ce98b05f34e7974749187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilia=20M=C3=A4kel=C3=A4?= Date: Tue, 25 Jun 2024 10:00:04 +0300 Subject: [PATCH] fix: fix applicant messager drawer refusing to close in some cases (#3110) (HL-1345) Closing the sidebar changed the isMessagesDrawerVisible value, which was a dependency for the same useEffect that was responsible for opening it upon the query parameter in the first place. Now that function is isolated into its own useEffect and doesn't get rerun. --- .../benefit/applicant/src/components/header/useHeader.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/benefit/applicant/src/components/header/useHeader.ts b/frontend/benefit/applicant/src/components/header/useHeader.ts index 57ea9e7908..14f45eeafa 100644 --- a/frontend/benefit/applicant/src/components/header/useHeader.ts +++ b/frontend/benefit/applicant/src/components/header/useHeader.ts @@ -67,10 +67,13 @@ const useHeader = (): ExtendedComponentProps => { if (isMessagesDrawerVisible && Number(unreadMessagesCount) > 0) { setUnredMessagesCount(null); } + }, [isMessagesDrawerVisible, unreadMessagesCount]); + + useEffect(() => { if (openDrawer) { setMessagesDrawerVisiblity(true); } - }, [isMessagesDrawerVisible, unreadMessagesCount, openDrawer]); + }, [openDrawer]); const status = React.useMemo( (): APPLICATION_STATUSES =>