Skip to content

Commit 4a54802

Browse files
fix: close popover when notification settings are clicked (coder#17001)
When a user clicks in the notification settings does not make sense to keep the popover open, instead, we want to close it.
1 parent 86d9071 commit 4a54802

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

site/src/modules/notifications/NotificationsInbox/InboxPopover.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { ScrollArea } from "components/ScrollArea/ScrollArea";
99
import { Spinner } from "components/Spinner/Spinner";
1010
import { RefreshCwIcon, SettingsIcon } from "lucide-react";
11-
import type { FC } from "react";
11+
import { type FC, useState } from "react";
1212
import { Link as RouterLink } from "react-router-dom";
1313
import { cn } from "utils/cn";
1414
import { InboxButton } from "./InboxButton";
@@ -34,8 +34,10 @@ export const InboxPopover: FC<InboxPopoverProps> = ({
3434
onMarkAllAsRead,
3535
onMarkNotificationAsRead,
3636
}) => {
37+
const [isOpen, setIsOpen] = useState(defaultOpen);
38+
3739
return (
38-
<Popover defaultOpen={defaultOpen}>
40+
<Popover open={isOpen} onOpenChange={setIsOpen}>
3941
<PopoverTrigger asChild>
4042
<InboxButton unreadCount={unreadCount} />
4143
</PopoverTrigger>
@@ -61,7 +63,10 @@ export const InboxPopover: FC<InboxPopoverProps> = ({
6163
Mark all as read
6264
</Button>
6365
<Button variant="outline" size="icon" asChild>
64-
<RouterLink to="/settings/notifications">
66+
<RouterLink
67+
to="/settings/notifications"
68+
onClick={() => setIsOpen(false)}
69+
>
6570
<SettingsIcon />
6671
<span className="sr-only">Notification settings</span>
6772
</RouterLink>

site/src/modules/notifications/NotificationsInbox/NotificationsInbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
} from "api/typesGenerated";
77
import { displayError } from "components/GlobalSnackbar/utils";
88
import { useEffectEvent } from "hooks/hookPolyfills";
9-
import { type FC, useEffect, useRef } from "react";
9+
import { type FC, useEffect } from "react";
1010
import { useMutation, useQuery, useQueryClient } from "react-query";
1111
import { InboxPopover } from "./InboxPopover";
1212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy