fix: inserted index out of boundr

This commit is contained in:
appflowy 2022-08-05 12:51:47 +08:00
parent e592a09ec3
commit 2e0256f305
2 changed files with 17 additions and 2 deletions

View File

@ -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();
}

View File

@ -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;