fix: hide toolbar if editor loses focus (#2066)

pull/2089/head v10.0.10
Huan Du 8 months ago committed by GitHub
parent 1e545ca298
commit cbcc023f03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 20
      lib/src/editor/editor.dart

@ -174,16 +174,28 @@ class QuillEditorState extends State<QuillEditor>
@override
void initState() {
super.initState();
widget.configurations.controller.editorFocusNode ??= widget.focusNode;
if (configurations.autoFocus) {
widget.configurations.controller.editorFocusNode?.requestFocus();
}
_editorKey = configurations.editorKey ?? GlobalKey<EditorState>();
_selectionGestureDetectorBuilder =
_QuillEditorSelectionGestureDetectorBuilder(
this,
configurations.detectWordBoundary,
);
final focusNode =
widget.configurations.controller.editorFocusNode ?? widget.focusNode;
widget.configurations.controller.editorFocusNode = focusNode;
if (configurations.autoFocus) {
focusNode.requestFocus();
}
// Hide toolbar when the editor loses focus.
focusNode.addListener(() {
if (!focusNode.hasFocus) {
_editorKey.currentState?.hideToolbar();
}
});
}
@override

Loading…
Cancel
Save