diff --git a/lib/src/widgets/editor.dart b/lib/src/widgets/editor.dart index e1f6d220..2a1bc5e3 100644 --- a/lib/src/widgets/editor.dart +++ b/lib/src/widgets/editor.dart @@ -182,6 +182,7 @@ class QuillEditor extends StatefulWidget { this.customShortcuts, this.customActions, this.detectWordBoundary = true, + this.enableUnfocusOnTapOutside = true, this.customLinkPrefixes = const [], Key? key}) : super(key: key); @@ -246,6 +247,9 @@ class QuillEditor extends StatefulWidget { /// Defaults to `false`. Cannot be `null`. final bool autoFocus; + /// Whether focus should be revoked on tap outside the editor. + final bool enableUnfocusOnTapOutside; + /// Whether to show cursor. /// /// The cursor refers to the blinking caret when the editor is focused. @@ -506,6 +510,7 @@ class QuillEditorState extends State customShortcuts: widget.customShortcuts, customActions: widget.customActions, customLinkPrefixes: widget.customLinkPrefixes, + enableUnfocusOnTapOutside: widget.enableUnfocusOnTapOutside, ); final editor = I18n( diff --git a/lib/src/widgets/raw_editor.dart b/lib/src/widgets/raw_editor.dart index 9531cbde..64059983 100644 --- a/lib/src/widgets/raw_editor.dart +++ b/lib/src/widgets/raw_editor.dart @@ -72,6 +72,7 @@ class RawEditor extends StatefulWidget { this.customActions, this.expands = false, this.autoFocus = false, + this.enableUnfocusOnTapOutside = true, this.keyboardAppearance = Brightness.light, this.enableInteractiveSelection = true, this.scrollPhysics, @@ -95,6 +96,7 @@ class RawEditor extends StatefulWidget { final ScrollController scrollController; final bool scrollable; final double scrollBottomInset; + final bool enableUnfocusOnTapOutside; /// Additional space around the editor contents. final EdgeInsetsGeometry padding; @@ -494,6 +496,7 @@ class RawEditorState extends EditorState maxHeight: widget.maxHeight ?? double.infinity); return TextFieldTapRegion( + enabled: widget.enableUnfocusOnTapOutside, onTapOutside: _defaultOnTapOutside, child: QuillStyles( data: _styles!,