mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: focusNode lost focus
This commit is contained in:
parent
2b113aae7f
commit
274b3d1d25
@ -208,7 +208,14 @@ class _PopupListWidgetState extends State<PopupListWidget> {
|
||||
}
|
||||
|
||||
if (event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
widget.items[selectedIndex].handler(widget.editorState);
|
||||
if (0 <= selectedIndex && selectedIndex < widget.items.length) {
|
||||
widget.items[selectedIndex].handler(widget.editorState);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
clearPopupListOverlay();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
|
@ -32,23 +32,23 @@ class FlowyKeyboard extends StatefulWidget {
|
||||
|
||||
class _FlowyKeyboardState extends State<FlowyKeyboard>
|
||||
with FlowyKeyboardService {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
||||
final FocusNode _focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
||||
|
||||
bool isFocus = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
focusNode: focusNode,
|
||||
autofocus: true,
|
||||
focusNode: _focusNode,
|
||||
onKey: _onKey,
|
||||
onFocusChange: _onFocusChange,
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
focusNode.dispose();
|
||||
_focusNode.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
@ -56,13 +56,17 @@ class _FlowyKeyboardState extends State<FlowyKeyboard>
|
||||
@override
|
||||
void enable() {
|
||||
isFocus = true;
|
||||
focusNode.requestFocus();
|
||||
_focusNode.requestFocus();
|
||||
}
|
||||
|
||||
@override
|
||||
void disable() {
|
||||
isFocus = false;
|
||||
focusNode.unfocus();
|
||||
_focusNode.unfocus();
|
||||
}
|
||||
|
||||
void _onFocusChange(bool value) {
|
||||
debugPrint('[KeyBoard Service] focus change $value');
|
||||
}
|
||||
|
||||
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
||||
|
@ -265,6 +265,8 @@ class _FlowySelectionState extends State<FlowySelection>
|
||||
}
|
||||
final selection = Selection.collapsed(position);
|
||||
editorState.updateCursorSelection(selection);
|
||||
|
||||
editorState.service.keyboardService?.enable();
|
||||
}
|
||||
|
||||
@override
|
||||
|
Loading…
Reference in New Issue
Block a user