Skip to content

Commit

Permalink
fix: solve the focus problem caused by monitoring onFocusChange and c…
Browse files Browse the repository at this point in the history
…hange to monitoring click events (#660)
  • Loading branch information
q200892907 authored Jan 10, 2024
1 parent 87eabfb commit 26c24ec
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class IgnoreEditorSelectionGesture extends StatefulWidget {
class _IgnoreEditorSelectionGestureState
extends State<IgnoreEditorSelectionGesture> {
final key = Random(10000).toString();
final FocusNode _focusNode = FocusNode();
late final SelectionGestureInterceptor interceptor;
late final EditorState editorState = context.read<EditorState>();

Expand Down Expand Up @@ -50,12 +49,14 @@ class _IgnoreEditorSelectionGestureState

@override
Widget build(BuildContext context) {
return Focus(
focusNode: _focusNode,
onFocusChange: (value) {
// current has focus ,close editor
if (value) {
editorState.selection = null;
return Listener(
onPointerDown: (event) {
final renderObject = context.findRenderObject();
// touch to clear
if (renderObject != null && renderObject is RenderBox) {
if (renderObject.paintBounds.contains(event.localPosition)) {
editorState.selection = null;
}
}
},
child: widget.child,
Expand Down

0 comments on commit 26c24ec

Please sign in to comment.