diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 497a40b286..2676139f71 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -261,7 +261,7 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, fileReader.readAsText(file) cb && cb(null, true) } - const name = `${targetFolder}/${file.name}` + const name = targetFolder === '/' ? file.name : `${targetFolder}/${file.name}` workspaceProvider.exists(name).then(exist => { if (!exist) { diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index 5ec5ab9827..f89fb9338e 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -169,9 +169,10 @@ export const FileExplorer = (props: FileExplorerProps) => { } const uploadFile = (target) => { - const parentFolder = getFocusedFolder() + let parentFolder = getFocusedFolder() const expandPath = [...new Set([...props.expandPath, parentFolder])] + parentFolder = parentFolder === name ? '/' : parentFolder props.dispatchHandleExpandPath(expandPath) props.dispatchUploadFile(target, parentFolder) }