[android] assigning a new Document to QuillController causes the keyboard to appear
Is there an existing issue for this?
- [X] I have searched the existing issues
Flutter Quill version
9.3.11 (edit : still there in 9.3.21)
Steps to reproduce
On Android (but not iOS), assigning a new Document object to the class member QuillController.document after the creation of the QuillEditor will cause the widget to gain focus and the soft keyboard to appear. I would like to load text when the user is taping a button, but this bug is preventing me from doing so.
Expected results
QuillEditor does not get the focus and the keyboard does not appear.
Actual results
QuillEditor get the focus and the keyboard appears.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart' as quill;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Quill Test',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final quill.QuillController _quillController = quill.QuillController.basic();
final FocusNode _editorFocusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: quill.QuillEditor(
focusNode: _editorFocusNode,
scrollController: ScrollController(),
configurations: quill.QuillEditorConfigurations(
placeholder: "Tap to add a comment",
controller: _quillController,
expands: false,
padding: EdgeInsets.zero,
)
),
),
floatingActionButton: FloatingActionButton(
onPressed: (){
_quillController.document = quill.Document(); // error: will make the keyboard appear!!
},
child: const Text("Load"),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Hi @apleton . Do you have any solution to fix it or any workaround?
The issue is still there in 9.3.21. As a workaround I create a new QuillController each time I want to load a document.
Thanks. I downgraded to version 9.3.5
Any update on this ? @apleton workaround works but a fix would be appreciated.
Still have the same issue with latest version 10.4.5.
We are having the same issue, and @apleton workaround works for us. However there are many scenarios we don't want to create new QuillController each time, so a fix would be appreciated.