fix(documents): MoveToFolderDialog — Root search + reset on reopen

cmdk filters by the CommandItem value prop, so the sentinel
"__root__" silently failed to match natural search terms like "no
folder". Use the human label instead. Also reset pickedId when the
dialog re-opens so a cancelled pick doesn't carry a stale highlight
into the next open.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 12:07:48 +02:00
parent e6103a4473
commit 4dd1fa4b24

View File

@@ -1,6 +1,6 @@
'use client';
import { useMemo, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { Check, FolderInput } from 'lucide-react';
import { toast } from 'sonner';
@@ -46,6 +46,10 @@ export function MoveToFolderDialog({
const move = useMoveDocument();
const [pickedId, setPickedId] = useState<string | null>(currentFolderId);
useEffect(() => {
if (open) setPickedId(currentFolderId);
}, [open, currentFolderId]);
const paths = useMemo(() => buildFolderPaths(tree), [tree]);
return (
@@ -60,7 +64,7 @@ export function MoveToFolderDialog({
<CommandEmpty>No folders match.</CommandEmpty>
<CommandGroup heading="Special">
<CommandItem
value="__root__"
value="Root (no folder)"
onSelect={() => setPickedId(null)}
className="flex items-center gap-2"
>