Skip to content

Commit 7be510f

Browse files
committed
chore: delay overlap dragtarget event
1 parent d941db2 commit 7be510f

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Log {
2828

2929
static void trace(String? message) {
3030
if (enableLog) {
31-
debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
31+
// debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');
3232
}
3333
}
3434
}

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class AFBoardDataController extends ChangeNotifier
197197
assert(index != -1);
198198
if (index != -1) {
199199
if (index != newIndex) {
200-
Log.debug(
200+
Log.trace(
201201
'[$BoardPhantomController] update $columnId:$index to $columnId:$newIndex');
202202
final item = columnDataController.removeAt(index, notify: false);
203203
columnDataController.insert(newIndex, item, notify: false);

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target_interceptor.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
5555
final String reorderFlexId;
5656
final List<String> acceptedReorderFlexId;
5757
final OverlapDragTargetDelegate delegate;
58+
Timer? _delayOperation;
5859

5960
OverlappingDragTargetInterceptor({
6061
required this.delegate,
@@ -77,12 +78,17 @@ class OverlappingDragTargetInterceptor extends DragTargetInterceptor {
7778
if (dragTargetId == dragTargetData.reorderFlexId) {
7879
delegate.cancel();
7980
} else {
80-
final index = delegate.canMoveTo(dragTargetId);
81-
Log.trace(
82-
'[$OverlappingDragTargetInterceptor] move to $dragTargetId at $index');
83-
if (index != -1) {
84-
delegate.moveTo(dragTargetId, dragTargetData, index);
85-
}
81+
/// The priority of the column interactions is high than the cross column.
82+
/// Workaround: delay 100 milliseconds to lower the cross column event priority.
83+
_delayOperation?.cancel();
84+
_delayOperation = Timer(const Duration(milliseconds: 100), () {
85+
final index = delegate.canMoveTo(dragTargetId);
86+
if (index != -1) {
87+
Log.trace(
88+
'[$OverlappingDragTargetInterceptor] move to $dragTargetId at $index');
89+
delegate.moveTo(dragTargetId, dragTargetData, index);
90+
}
91+
});
8692
}
8793

8894
return true;

frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ class ReorderFlexState extends State<ReorderFlex>
437437
/// The [willAccept] will be true if the dargTarget is the widget that gets
438438
/// dragged and it is dragged on top of the other dragTargets.
439439
///
440-
Log.debug(
440+
Log.trace(
441441
'[$ReorderDragTarget] ${widget.dataSource.identifier} on will accept, dragIndex:$dragIndex, dragTargetIndex:$dragTargetIndex, count: ${widget.dataSource.items.length}');
442442

443443
bool willAccept =

0 commit comments

Comments
 (0)