Skip to content

Commit fb30989

Browse files
committed
fix: #1763 [Bug] Mouse unable to click a certain area
1 parent 5de3912 commit fb30989

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

frontend/app_flowy/packages/appflowy_editor/example/assets/example.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
]
2424
},
2525
{ "type": "text", "delta": [] },
26-
{ "type": "board" },
2726
{
2827
"type": "text",
2928
"delta": [

frontend/app_flowy/packages/appflowy_editor/lib/src/service/internal_key_event_handlers/enter_without_shift_in_text_node_handler.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ ShortcutEventHandler enterWithoutShiftInTextNodesHandler =
8080
final transaction = editorState.transaction
8181
..updateNode(textNode, {
8282
BuiltInAttributeKey.subtype: null,
83+
textNode.subtype!: null,
8384
})
8485
..afterSelection = afterSelection;
8586
editorState.apply(transaction);

frontend/app_flowy/packages/appflowy_editor/lib/src/service/render_plugin_service.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ class AppFlowyRenderPlugin extends AppFlowyRenderPluginService {
7777
return _autoUpdateNodeWidget(builder, context);
7878
} else {
7979
// Returns a SizeBox with 0 height if no builder found.
80-
return const SizedBox(
80+
assert(
81+
false,
82+
'No builder found for node(${node.id}, attributes(${node.attributes})})',
83+
);
84+
return SizedBox(
85+
key: node.key,
8186
height: 0,
8287
);
8388
}

frontend/app_flowy/packages/appflowy_editor/test/render/rich_text/checkbox_text_test.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:appflowy_editor/appflowy_editor.dart';
22
import 'package:appflowy_editor/src/extensions/text_node_extensions.dart';
3+
import 'package:flutter/services.dart';
34
import 'package:flutter_test/flutter_test.dart';
45
import '../../infra/test_editor.dart';
56

@@ -67,5 +68,61 @@ void main() async {
6768
expect(node.allSatisfyUnderlineInSelection(selection), true);
6869
expect(node.allSatisfyStrikethroughInSelection(selection), true);
6970
});
71+
72+
// https://github.com/AppFlowy-IO/AppFlowy/issues/1763
73+
// [Bug] Mouse unable to click a certain area #1763
74+
testWidgets('insert a new checkbox after an exsiting checkbox',
75+
(tester) async {
76+
// Before
77+
//
78+
// [checkbox] Welcome to Appflowy 😁
79+
//
80+
// After
81+
//
82+
// [checkbox] Welcome to Appflowy 😁
83+
//
84+
// [checkbox] Welcome to Appflowy 😁
85+
//
86+
const text = 'Welcome to Appflowy 😁';
87+
final editor = tester.editor
88+
..insertTextNode(
89+
'',
90+
attributes: {
91+
BuiltInAttributeKey.subtype: BuiltInAttributeKey.checkbox,
92+
BuiltInAttributeKey.checkbox: false,
93+
},
94+
delta: Delta(
95+
operations: [TextInsert(text)],
96+
),
97+
);
98+
await editor.startTesting();
99+
await editor.updateSelection(
100+
Selection.single(path: [0], startOffset: text.length),
101+
);
102+
103+
await editor.pressLogicKey(LogicalKeyboardKey.enter);
104+
await editor.pressLogicKey(LogicalKeyboardKey.enter);
105+
await editor.pressLogicKey(LogicalKeyboardKey.enter);
106+
107+
expect(
108+
editor.documentSelection,
109+
Selection.single(path: [2], startOffset: 0),
110+
);
111+
112+
await editor.pressLogicKey(LogicalKeyboardKey.slash);
113+
await tester.pumpAndSettle(const Duration(milliseconds: 1000));
114+
115+
expect(
116+
find.byType(SelectionMenuWidget, skipOffstage: false),
117+
findsOneWidget,
118+
);
119+
120+
final checkboxMenuItem = find.text('Checkbox', findRichText: true);
121+
await tester.tap(checkboxMenuItem);
122+
await tester.pumpAndSettle();
123+
124+
final checkboxNode = editor.nodeAtPath([2]) as TextNode;
125+
expect(checkboxNode.subtype, BuiltInAttributeKey.checkbox);
126+
});
70127
});
71128
}

0 commit comments

Comments
 (0)