fix: close popover when notification settings are clicked (#17001)

When a user clicks in the notification settings does not make sense to
keep the popover open, instead, we want to close it.
This commit is contained in:
Bruno Quaresma
2025-03-19 10:52:04 -03:00
committed by GitHub
parent 86d907126d
commit 4a548021c3
2 changed files with 9 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import {
import { ScrollArea } from "components/ScrollArea/ScrollArea"; import { ScrollArea } from "components/ScrollArea/ScrollArea";
import { Spinner } from "components/Spinner/Spinner"; import { Spinner } from "components/Spinner/Spinner";
import { RefreshCwIcon, SettingsIcon } from "lucide-react"; import { RefreshCwIcon, SettingsIcon } from "lucide-react";
import type { FC } from "react"; import { type FC, useState } from "react";
import { Link as RouterLink } from "react-router-dom"; import { Link as RouterLink } from "react-router-dom";
import { cn } from "utils/cn"; import { cn } from "utils/cn";
import { InboxButton } from "./InboxButton"; import { InboxButton } from "./InboxButton";
@ -34,8 +34,10 @@ export const InboxPopover: FC<InboxPopoverProps> = ({
onMarkAllAsRead, onMarkAllAsRead,
onMarkNotificationAsRead, onMarkNotificationAsRead,
}) => { }) => {
const [isOpen, setIsOpen] = useState(defaultOpen);
return ( return (
<Popover defaultOpen={defaultOpen}> <Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<InboxButton unreadCount={unreadCount} /> <InboxButton unreadCount={unreadCount} />
</PopoverTrigger> </PopoverTrigger>
@ -61,7 +63,10 @@ export const InboxPopover: FC<InboxPopoverProps> = ({
Mark all as read Mark all as read
</Button> </Button>
<Button variant="outline" size="icon" asChild> <Button variant="outline" size="icon" asChild>
<RouterLink to="/settings/notifications"> <RouterLink
to="/settings/notifications"
onClick={() => setIsOpen(false)}
>
<SettingsIcon /> <SettingsIcon />
<span className="sr-only">Notification settings</span> <span className="sr-only">Notification settings</span>
</RouterLink> </RouterLink>

View File

@ -6,7 +6,7 @@ import type {
} from "api/typesGenerated"; } from "api/typesGenerated";
import { displayError } from "components/GlobalSnackbar/utils"; import { displayError } from "components/GlobalSnackbar/utils";
import { useEffectEvent } from "hooks/hookPolyfills"; import { useEffectEvent } from "hooks/hookPolyfills";
import { type FC, useEffect, useRef } from "react"; import { type FC, useEffect } from "react";
import { useMutation, useQuery, useQueryClient } from "react-query"; import { useMutation, useQuery, useQueryClient } from "react-query";
import { InboxPopover } from "./InboxPopover"; import { InboxPopover } from "./InboxPopover";