diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index 9948e14f..0d3f0a25 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -411,6 +411,8 @@ class RawEditorState extends EditorState void _handleCheckboxTap(int offset, bool value) { if (!widget.readOnly) { _disableScrollControllerAnimateOnce = true; + widget.controller.ignoreFocusOnTextChange = true; + final currentSelection = widget.controller.selection.copyWith(); final attribute = value ? Attribute.checked : Attribute.unchecked; widget.controller.formatText(offset, 0, attribute); @@ -424,8 +426,8 @@ class RawEditorState extends EditorState // Go back from offset 0 to current selection SchedulerBinding.instance.addPostFrameCallback((_) { - widget.controller.updateSelection( - TextSelection.collapsed(offset: offset), ChangeSource.LOCAL); + widget.controller.ignoreFocusOnTextChange = false; + widget.controller.updateSelection(currentSelection, ChangeSource.LOCAL); }); } }