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:
@ -208,7 +208,14 @@ class _PopupListWidgetState extends State<PopupListWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.logicalKey == LogicalKeyboardKey.enter) {
|
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;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,23 +32,23 @@ class FlowyKeyboard extends StatefulWidget {
|
|||||||
|
|
||||||
class _FlowyKeyboardState extends State<FlowyKeyboard>
|
class _FlowyKeyboardState extends State<FlowyKeyboard>
|
||||||
with FlowyKeyboardService {
|
with FlowyKeyboardService {
|
||||||
final FocusNode focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
final FocusNode _focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
||||||
|
|
||||||
bool isFocus = true;
|
bool isFocus = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Focus(
|
return Focus(
|
||||||
focusNode: focusNode,
|
focusNode: _focusNode,
|
||||||
autofocus: true,
|
|
||||||
onKey: _onKey,
|
onKey: _onKey,
|
||||||
|
onFocusChange: _onFocusChange,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
focusNode.dispose();
|
_focusNode.dispose();
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@ -56,13 +56,17 @@ class _FlowyKeyboardState extends State<FlowyKeyboard>
|
|||||||
@override
|
@override
|
||||||
void enable() {
|
void enable() {
|
||||||
isFocus = true;
|
isFocus = true;
|
||||||
focusNode.requestFocus();
|
_focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void disable() {
|
void disable() {
|
||||||
isFocus = false;
|
isFocus = false;
|
||||||
focusNode.unfocus();
|
_focusNode.unfocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onFocusChange(bool value) {
|
||||||
|
debugPrint('[KeyBoard Service] focus change $value');
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {
|
||||||
|
@ -265,6 +265,8 @@ class _FlowySelectionState extends State<FlowySelection>
|
|||||||
}
|
}
|
||||||
final selection = Selection.collapsed(position);
|
final selection = Selection.collapsed(position);
|
||||||
editorState.updateCursorSelection(selection);
|
editorState.updateCursorSelection(selection);
|
||||||
|
|
||||||
|
editorState.service.keyboardService?.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Reference in New Issue
Block a user