Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] assigning a new Document to QuillController causes the keyboard to appear #1870

Open
1 task done
apleton opened this issue May 17, 2024 · 3 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@apleton
Copy link

apleton commented May 17, 2024

Is there an existing issue for this?

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]
@apleton apleton added the bug Something isn't working label May 17, 2024
@apleton apleton changed the title [android] assigning a new Document to QuillController makes the keyboard appear [android] assigning a new Document to QuillController causes the keyboard to appear May 17, 2024
@thanglq1
Copy link

thanglq1 commented Jun 1, 2024

Hi @apleton . Do you have any solution to fix it or any workaround?

@apleton
Copy link
Author

apleton commented Jun 1, 2024

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.

@thanglq1
Copy link

thanglq1 commented Jun 1, 2024

Thanks. I downgraded to version 9.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants