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