Ver Fonte

fix: inserted index out of boundr

appflowy há 2 anos atrás
pai
commit
2e0256f305

+ 7 - 1
frontend/app_flowy/packages/flowy_board/lib/src/widgets/board_column/data_controller.dart

@@ -71,7 +71,13 @@ class BoardColumnDataController extends ChangeNotifier
   void insert(int index, ColumnItem item, {bool notify = true}) {
     Log.debug(
         '[$BoardColumnDataController] $columnData insert $item at $index');
-    columnData._items.insert(index, item);
+
+    if (columnData._items.length > index) {
+      columnData._items.insert(index, item);
+    } else {
+      columnData._items.add(item);
+    }
+
     if (notify) {
       notifyListeners();
     }

+ 10 - 1
frontend/app_flowy/packages/flowy_board/lib/src/widgets/flex/drag_target_inteceptor.dart

@@ -25,6 +25,11 @@ abstract class ReorderFlexDragTargetInterceptor {
 
 abstract class OverlapReorderFlexDragTargetDelegate {
   void dragTargetDidDisappear();
+  bool acceptNewDragTargetData(
+    String reorderFlexId,
+    FlexDragTargetData dragTargetData,
+    int dragTargetIndex,
+  );
 }
 
 class OverlapReorderFlexDragTargetInteceptor
@@ -54,7 +59,11 @@ class OverlapReorderFlexDragTargetInteceptor
     if (dragTargetId == dragTargetData.reorderFlexId) {
       delegate.dragTargetDidDisappear();
     } else {
-      Log.debug('add phantom to $dragTargetId');
+      delegate.acceptNewDragTargetData(
+        dragTargetId,
+        dragTargetData,
+        dragTargetIndex,
+      );
     }
 
     return true;