Parcourir la source

Fix isDroppable method

https://youtrack.weseek.co.jp/issue/GW-7923
- Update isDropable condition
- Compare target bookmark folder id with dropped bookamark's parent folder
- Update Type of DragItemDataType
Mudana-Grune il y a 3 ans
Parent
commit
a4c8624cbd
1 fichiers modifiés avec 3 ajouts et 4 suppressions
  1. 3 4
      packages/app/src/components/Bookmarks/BookmarkFolderItem.tsx

+ 3 - 4
packages/app/src/components/Bookmarks/BookmarkFolderItem.tsx

@@ -31,7 +31,7 @@ type BookmarkFolderItemProps = {
   isUserHomePage?: boolean
 }
 
-type DragItemDataType = BookmarkFolderItemProps & IPageHasId;
+type DragItemDataType = BookmarkFolderItemProps & IPageHasId & { parentFolder: BookmarkFolderItems } ;
 
 const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderItemProps) => {
   const acceptedTypes: DragItemType[] = [DRAG_ITEM_TYPE.FOLDER, DRAG_ITEM_TYPE.BOOKMARK];
@@ -173,9 +173,8 @@ const BookmarkFolderItem: FC<BookmarkFolderItemProps> = (props: BookmarkFolderIt
       }
       return item.root !== targetRoot || item.level >= targetLevel;
     }
-    const bookmarks = bookmarkFolder.bookmarks;
-    const isBookmarkExists = bookmarks.filter(bookmark => bookmark.page._id === item._id).length > 0;
-    if (isBookmarkExists) {
+    const isSameTarget = item.parentFolder && item.parentFolder._id === bookmarkFolder._id;
+    if (isSameTarget) {
       return false;
     }
     return true;