mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
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:
@ -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>
|
||||||
|
@ -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";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user