Просмотр исходного кода

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 3 лет назад
Родитель
Сommit
a4c8624cbd
1 измененных файлов с 3 добавлено и 4 удалено
  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;