From e4daa6982a379c766bbd8d6f02723cc6cd80ccb6 Mon Sep 17 00:00:00 2001 From: Xu Quan Date: Sun, 13 Jul 2025 16:57:57 +0800 Subject: [PATCH] fix: avoid duplicate key in files list when focus on tag --- src/components/FileTree/PinnedFiles.tsx | 6 +++--- src/components/FileTree/index.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/FileTree/PinnedFiles.tsx b/src/components/FileTree/PinnedFiles.tsx index 1dcf32c..b623894 100644 --- a/src/components/FileTree/PinnedFiles.tsx +++ b/src/components/FileTree/PinnedFiles.tsx @@ -8,7 +8,7 @@ import { ExplorerStore } from "src/store"; import { PinContainer, PinContent, PinHeader } from "../Pin"; type Props = { - renderFile: (file: TFile, disableDrag?: boolean) => ReactNode; + renderFile: (file: TFile, index: number, disableDrag?: boolean) => ReactNode; }; const PinnedFiles = ({ renderFile }: Props) => { const { useExplorerStore } = useExplorer(); @@ -26,8 +26,8 @@ const PinnedFiles = ({ renderFile }: Props) => { - {getDisplayedPinnedFiles().map((file) => - renderFile(file, true) + {getDisplayedPinnedFiles().map((file, index) => + renderFile(file, index, true) )} diff --git a/src/components/FileTree/index.tsx b/src/components/FileTree/index.tsx index 5aa0b5e..3bec9a0 100644 --- a/src/components/FileTree/index.tsx +++ b/src/components/FileTree/index.tsx @@ -27,9 +27,9 @@ const FileTree = ({ onOpenFoldersPane = () => {} }: Props) => { ); const { files } = useChangeFile(); - const renderFile = (file: TFile, disableDrag?: boolean) => ( + const renderFile = (file: TFile, index: number, disableDrag?: boolean) => ( {} }: Props) => { return (
- {sortedFiles.map((file) => renderFile(file))} + {sortedFiles.map((file, index) => renderFile(file, index))}
); };