Skip to content

Commit 5c1b084

Browse files
authored
fix: cursor doesn't blink when opening selection menu (#1622)
* fix: cursor doesn't blink when opening selection menu * chore: fix dart lint
1 parent b09f37e commit 5c1b084

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

frontend/app_flowy/packages/appflowy_editor/lib/src/render/selection_menu/selection_menu_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class SelectionMenu implements SelectionMenuService {
111111

112112
Overlay.of(context)?.insert(_selectionMenuEntry!);
113113

114-
editorState.service.keyboardService?.disable();
114+
editorState.service.keyboardService?.disable(showCursor: true);
115115
editorState.service.scrollService?.disable();
116116
selectionService.currentSelection.addListener(_onSelectionChange);
117117
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class AppFlowyKeyboardService {
3535
/// you can disable the keyboard service of flowy_editor.
3636
/// But you need to call the `enable` function to restore after exiting
3737
/// your custom component, otherwise the keyboard service will fails.
38-
void disable();
38+
void disable({bool showCursor = false});
3939
}
4040

4141
/// Process keyboard events
@@ -62,6 +62,7 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
6262
final FocusNode _focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
6363

6464
bool isFocus = true;
65+
bool showCursor = false;
6566

6667
@override
6768
List<ShortcutEvent> get shortcutEvents => widget.shortcutEvents;
@@ -101,8 +102,9 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
101102
}
102103

103104
@override
104-
void disable() {
105+
void disable({bool showCursor = false}) {
105106
isFocus = false;
107+
this.showCursor = showCursor;
106108
_focusNode.unfocus();
107109
}
108110

@@ -137,8 +139,10 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
137139
void _onFocusChange(bool value) {
138140
Log.keyboard.debug('on keyboard event focus change $value');
139141
isFocus = value;
140-
if (!value) {
142+
if (!value && !showCursor) {
141143
widget.editorState.service.selectionService.clearCursor();
144+
} else {
145+
showCursor = false;
142146
}
143147
}
144148

frontend/app_flowy/packages/appflowy_editor_plugins/lib/src/emoji_picker/emoji_menu_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
55
import 'emoji_picker.dart';
66

77
SelectionMenuItem emojiMenuItem = SelectionMenuItem(
8-
name: () => 'emoji',
8+
name: () => 'Emoji',
99
icon: (editorState, onSelected) => Icon(
1010
Icons.emoji_emotions_outlined,
1111
color: onSelected

0 commit comments

Comments
 (0)