fix: on ui event reset selection type (#555)

* fix: on ui event reset selection type

* test: add test
This commit is contained in:
Mathias Mogensen 2023-10-30 04:20:42 +01:00 • committed by GitHub
commit 7336274ff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -160,5 +160,29 @@ void main() async {
await editor.dispose();
});
testWidgets('Block selection and then single tap', (tester) async {
const text = 'Welcome to Appflowy 😁';
final editor = tester.editor..addParagraph(initialText: text);
await editor.startTesting();
final firstNode = editor.nodeAtPath([0]);
final finder = find.byKey(firstNode!.key);
final rect = tester.getRect(finder);
editor.editorState.selectionType = SelectionType.block;
// tap at the beginning
await tester.tapAt(rect.centerLeft);
expect(
editor.selection,
Selection.single(path: [0], startOffset: 0),
);
expect(editor.editorState.selectionType, SelectionType.inline);
await editor.dispose();
});
});
}