From 5575d226b914ec604655b77cee0d9a2be00f69a5 Mon Sep 17 00:00:00 2001 From: Arshak Aghakaryan Date: Mon, 27 Dec 2021 19:25:45 +0400 Subject: [PATCH] Do not show caret on screen when the editor is not focused For some reason, `RawEditorState.initState` is called every time I focus a `TextField` inside a scrollable view which uses the `ScrollController` that is passed to `QuillEditor.scrollController`. And, `RawEditorState.initState` calls `RawEditorState._onChangeTextEditingValue` which make sure that caret is visible on the screen if `ignoreCaret` is not `true`. In this commit I set `ignoreCaret` to opposite of `_hasFocus` so that caret is displayed only when the text field is focused. These changes make it easier to use `QuillEditor` in a list with other text fields. --- lib/src/widgets/raw_editor.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index 506020a1..556716cc 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -422,7 +422,7 @@ class RawEditorState extends EditorState _keyboardVisibilityController?.onChange.listen((visible) { _keyboardVisible = visible; if (visible) { - _onChangeTextEditingValue(); + _onChangeTextEditingValue(!_hasFocus); } }); }