Skip to content

Commit cc9bd30

Browse files
authored
fix: #1290 [Bug] 300ms delay on buttons in titlebar (#1789)
1 parent addcabe commit cc9bd30

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flowy_infra/theme_extension.dart';
22
import 'package:flowy_infra/size.dart';
33
import 'package:flowy_infra_ui/style_widget/hover.dart';
44
import 'package:flowy_infra_ui/style_widget/text.dart';
5+
import 'package:flowy_infra_ui/widget/ignore_parent_gesture.dart';
56
import 'package:flowy_infra_ui/widget/spacing.dart';
67
import 'package:flutter/material.dart';
78
import 'package:textstyle_extensions/textstyle_extensions.dart';
@@ -176,7 +177,12 @@ class FlowyTextButton extends StatelessWidget {
176177
highlightColor: Colors.transparent,
177178
elevation: 0,
178179
constraints: constraints,
179-
onPressed: onPressed,
180+
onPressed: () {},
181+
child: child,
182+
);
183+
184+
child = IgnoreParentGestureWidget(
185+
onPress: onPressed,
180186
child: child,
181187
);
182188

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:flutter/material.dart';
2+
3+
class IgnoreParentGestureWidget extends StatelessWidget {
4+
const IgnoreParentGestureWidget({
5+
Key? key,
6+
required this.child,
7+
this.onPress,
8+
}) : super(key: key);
9+
10+
final Widget child;
11+
final VoidCallback? onPress;
12+
13+
@override
14+
Widget build(BuildContext context) {
15+
// https://docs.flutter.dev/development/ui/advanced/gestures#gesture-disambiguation
16+
// https://github.com/AppFlowy-IO/AppFlowy/issues/1290
17+
return Listener(
18+
onPointerDown: (event) {
19+
onPress?.call();
20+
},
21+
onPointerSignal: (event) {},
22+
onPointerMove: (event) {},
23+
onPointerUp: (event) {},
24+
onPointerHover: (event) {},
25+
onPointerPanZoomStart: (event) {},
26+
onPointerPanZoomUpdate: (event) {},
27+
onPointerPanZoomEnd: (event) {},
28+
child: child,
29+
);
30+
}
31+
}

0 commit comments

Comments
 (0)