import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { Popover, PopoverTrigger, PopoverContent, } from "~/components/primitives/Popover"; import useStores from "~/hooks/useStores"; import Notifications from "./Notifications"; type Props = { children?: React.ReactNode; }; const NotificationsPopover: React.FC = ({ children }: Props) => { const { t } = useTranslation(); const { notifications } = useStores(); const [open, setOpen] = React.useState(false); const scrollableRef = React.useRef(null); React.useEffect(() => { void notifications.fetchPage({ archived: false }); }, [notifications]); const handleRequestClose = React.useCallback(() => { setOpen(false); }, []); const handleAutoFocus = React.useCallback((event: Event) => { // Prevent focus from moving to the popover content event.preventDefault(); // Reset scroll position to the top when popover is opened if (scrollableRef.current) { scrollableRef.current.scrollTop = 0; scrollableRef.current.focus(); } }, []); return ( {children} ); }; export default observer(NotificationsPopover);