我正在使用nextJS与shadcn,并有以下问题.我试图打开一个对话框从菜单,但它不打开,它只是关闭菜单.我的猜测是,要么我需要使用ref和状态,或者我需要把alertdialog在不同的地方这里是代码:
return (
<AlertDialog>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="w-8 h-8 p-0">
<span className="sr-only">Open Menu</span>
<FiMoreHorizontal className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="center">
<DropdownMenuSeparator />
<DropdownMenuItem className="justify-start cursor-pointer">
<Link href={`/dashboard/profile/trainee/${traineeId}`}>
Profile
</Link>
</DropdownMenuItem>
<DropdownMenuItem className="justify-start cursor-pointer">
<Link href={`/dashboard/profile/trainee/${traineeId}/escort/add-escort`}>
Add Escort
</Link>
</DropdownMenuItem>
<DropdownMenuItem className="justify-start cursor-pointer">
<AlertDialogTrigger>
Delete Trainee
</AlertDialogTrigger>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure you wish to delete the trainee?</AlertDialogTitle>
<AlertDialogDescription>
This will delete the trainee and all of his data.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={() => deleteTrainee(traineeId)}>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
字符串
1条答案
按热度按时间6mw9ycah1#
你需要把对话框外的屏幕菜单:检查预置行动在右上角的这个页面的例子:https://ui.shadcn.com/examples/playground
验证码:
字符串