Skip to content

Commit 05f2b0c

Browse files
committed
fix issue with session modal not automatically closing
1 parent 5a6fdd5 commit 05f2b0c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

apps/web/src/components/Sidebar/Sidebar.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from 'react';
2+
13
import { toBasicISOString, toLowerCase } from '@douglasneuroinformatics/libjs';
24
import { Button, Dialog, LanguageToggle, ThemeToggle } from '@douglasneuroinformatics/libui/components';
35
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
@@ -14,6 +16,8 @@ import { NavButton } from '../NavButton';
1416
import { UserDropup } from '../UserDropup';
1517

1618
export const Sidebar = () => {
19+
const [isEndSessionModalOpen, setIsEndSessionModalOpen] = useState(false);
20+
1721
const navItems = useNavItems();
1822
const currentSession = useAppStore((store) => store.currentSession);
1923
const endSession = useAppStore((store) => store.endSession);
@@ -43,7 +47,7 @@ export const Sidebar = () => {
4347
/>
4448
))}
4549
{i === navItems.length - 1 && (
46-
<Dialog>
50+
<Dialog open={isEndSessionModalOpen} onOpenChange={setIsEndSessionModalOpen}>
4751
<Dialog.Trigger asChild>
4852
<NavButton
4953
disabled={currentSession === null}
@@ -63,12 +67,19 @@ export const Sidebar = () => {
6367
className="min-w-20"
6468
onClick={() => {
6569
endSession();
66-
void navigate({ to: '/session/start-session' });
70+
void navigate({ to: '/session/start-session' }).then(() => {
71+
setIsEndSessionModalOpen(false);
72+
});
6773
}}
6874
>
6975
{t('core.yes')}
7076
</Button>
71-
<Button className="min-w-20" variant="outline">
77+
<Button
78+
className="min-w-20"
79+
type="button"
80+
variant="outline"
81+
onClick={() => setIsEndSessionModalOpen(false)}
82+
>
7283
{t('core.no')}
7384
</Button>
7485
</Dialog.Footer>

0 commit comments

Comments
 (0)