Procházet zdrojové kódy

Merge pull request #5340 from weseek/fix/88258-prevent-items-hidden-when-dropped-outside-the-page-tree

fix: 88258 Prevent items hidden when dropped outside the PageTree
Yuki Takei před 4 roky
rodič
revize
c47233038b

+ 5 - 2
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -108,9 +108,12 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
   const [{ isDragging }, drag] = useDrag(() => ({
   const [{ isDragging }, drag] = useDrag(() => ({
     type: 'PAGE_TREE',
     type: 'PAGE_TREE',
     item: { page },
     item: { page },
-    end: () => {
+    end: (item, monitor) => {
       // in order to set d-none to dropped Item
       // in order to set d-none to dropped Item
-      setShouldHide(true);
+      const dropResult = monitor.getDropResult();
+      if (dropResult != null) {
+        setShouldHide(true);
+      }
     },
     },
     collect: monitor => ({
     collect: monitor => ({
       isDragging: monitor.isDragging(),
       isDragging: monitor.isDragging(),