Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: disable children receive events under fake drag target

appflowyd941db29a133
diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart
index 57bd7343d9..621179455a 100644
--- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart
+++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/drag_target.dart
@@ -277,6 +277,31 @@ class IgnorePointerWidget extends StatelessWidget {
}
}
+class AbsorbPointerWidget extends StatelessWidget {
+ final Widget? child;
+ final bool useIntrinsicSize;
+ const AbsorbPointerWidget({
+ required this.child,
+ this.useIntrinsicSize = false,
+ Key? key,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ final sizedChild = useIntrinsicSize
+ ? child
+ : SizedBox(width: 0.0, height: 0.0, child: child);
+
+ final opacity = useIntrinsicSize ? 0.3 : 0.0;
+ return AbsorbPointer(
+ child: Opacity(
+ opacity: opacity,
+ child: sizedChild,
+ ),
+ );
+ }
+}
+
class PhantomWidget extends StatelessWidget {
final Widget? child;
final double opacity;
@@ -442,7 +467,7 @@ class _FakeDragTargetState<T extends DragTargetData>
return SizeTransitionWithIntrinsicSize(
sizeFactor: widget.deleteAnimationController,
axis: Axis.vertical,
- child: IgnorePointerWidget(
+ child: AbsorbPointerWidget(
child: widget.child,
),
);
@@ -450,7 +475,7 @@ class _FakeDragTargetState<T extends DragTargetData>
return SizeTransitionWithIntrinsicSize(
sizeFactor: widget.insertAnimationController,
axis: Axis.vertical,
- child: IgnorePointerWidget(
+ child: AbsorbPointerWidget(
useIntrinsicSize: true,
child: widget.child,
),
diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart
index 42f356542b..45a7ce2392 100644
--- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart
+++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_phantom/phantom_controller.dart
@@ -204,16 +204,16 @@ class BoardPhantomController extends OverlapDragTargetDelegate
@override
int canMoveTo(String dragTargetId) {
- // if (columnsState.isDragging(dragTargetId)) {
- // return -1;
- // }
-
- // final controller = delegate.controller(dragTargetId);
- // if (controller != null) {
- // return controller.columnData.items.length;
- // } else {
- // return 0;
- // }
+ if (columnsState.isDragging(dragTargetId)) {
+ return -1;
+ }
+
+ final controller = delegate.controller(dragTargetId);
+ if (controller != null) {
+ return controller.columnData.items.length;
+ } else {
+ return 0;
+ }
if (delegate.controller(dragTargetId)?.columnData.items.isEmpty ?? false) {
return 0;