"use client"; import { FC, useState } from "react"; import { IconProps } from "../../icons/Icon.js"; import { useCloseDropdown } from "./DropdownContext.js"; import { DropdownMenuItemLayout } from "./DropdownMenuItemLayout.js"; type AsyncActionItemProps = { icon?: FC; title: string; onClick(): Promise; // deprecated, this component will obtain the correct close automatically from dropdown context close?: () => void; }; export const DropdownMenuAsyncActionItem: FC = ({ title, icon, onClick, }) => { const closeDropdown = useCloseDropdown(); const [acting, setActing] = useState(false); const act = async () => { if (acting) { return; } setActing(true); await onClick(); setActing(false); closeDropdown(); }; return (
); };