feat: enhance DirectoryNode interaction with improved click handling and context menu support
This commit is contained in:
@@ -388,31 +388,32 @@ function DirectoryNode({
|
|||||||
<ContextMenuTrigger className="block">
|
<ContextMenuTrigger className="block">
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"group flex items-center gap-1 px-2 py-1.5 text-sm hover:bg-accent",
|
"group flex cursor-pointer items-center gap-1 px-2 py-1.5 text-sm hover:bg-accent",
|
||||||
active && "bg-accent text-accent-foreground",
|
active && "bg-accent text-accent-foreground",
|
||||||
)}
|
)}
|
||||||
style={{ paddingLeft: 8 + depth * 16 }}
|
style={{ paddingLeft: 8 + depth * 16 }}
|
||||||
|
onClick={() => onSelect(item.id)}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="size-5 shrink-0"
|
className="size-5 shrink-0"
|
||||||
disabled={!hasChildren}
|
disabled={!hasChildren}
|
||||||
onClick={() => onToggle(item.id)}
|
onClick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
onToggle(item.id);
|
||||||
|
}}
|
||||||
aria-label={expanded ? t("knowledge.collapseDirectory") : t("knowledge.expandDirectory")}
|
aria-label={expanded ? t("knowledge.collapseDirectory") : t("knowledge.expandDirectory")}
|
||||||
>
|
>
|
||||||
{expanded ? <ChevronDownIcon className="size-3.5" /> : <ChevronRightIcon className="size-3.5" />}
|
{expanded ? <ChevronDownIcon className="size-3.5" /> : <ChevronRightIcon className="size-3.5" />}
|
||||||
</Button>
|
</Button>
|
||||||
<FolderIcon className="size-4 shrink-0 text-muted-foreground" />
|
<FolderIcon className="size-4 shrink-0 text-muted-foreground" />
|
||||||
<button
|
<span className="min-w-0 flex-1 truncate text-left">
|
||||||
type="button"
|
|
||||||
className="min-w-0 flex-1 truncate text-left"
|
|
||||||
onClick={() => onSelect(item.id)}
|
|
||||||
>
|
|
||||||
{item.name}
|
{item.name}
|
||||||
</button>
|
</span>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger
|
<DropdownMenuTrigger
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
render={
|
render={
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|||||||
Reference in New Issue
Block a user