fleather-editor / fleather

Soft and gentle rich text editing for Flutter applications.
https://fleather-editor.github.io
Other
189 stars 32 forks source link

Keyboard pops back open when using the back gesture on Android #377

Closed maelchiotti closed 1 month ago

maelchiotti commented 1 month ago

A user of my app first reported this issue where the keyboard pops back up when he uses the back gesture on Android. Here is his screen recording:

https://github.com/user-attachments/assets/e37a13d4-db7c-4ea8-b5be-8d2ce321a4e9

I tried to reproduce it on my Android 12 device but I couldn't. I then set up an Android 14 emulator, and partly managed to reproduce the issue. In his case, he seems to able to do it indefinitely. However, I can only have the keyboard pop back up once, and then the keyboard is correctly hidden if I do the back gesture again.

I do not see any errors in the console. I also cannot reproduce this using a standard flutter TextField.

Steps to Reproduce

  1. Tap on a FleatherField or a FleatherEditor
  2. Try to hide the keyboard using the back gesture

Environment

Reproducible example

import 'package:fleather/fleather.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Tests',
      theme: ThemeData(
        useMaterial3: true,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key});

  final controller = FleatherController(document: ParchmentDocument());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Tests'),
      ),
      body: Column(
        children: [
          const TextField(),
          FleatherEditor(controller: controller),
        ],
      ),
    );
  }
}
amantoux commented 1 month ago

I'll take a look

amantoux commented 1 month ago

I manage to reproduce After typing some text, you need to position the cursor elsewhere on the editor before performing the back gesture to reproduce systematically

There are quite a few TextEditingDeltaNonTextUpdate that flow in when the back gesture is performed. I need to dig a little more

amantoux commented 1 month ago

As soon as I started debugging the native Flutter plugin, the symtom disappeared. Since then I'm unable to reproduce... @Amir-P would you be able to reproduce?

Amir-P commented 1 month ago

I'm able to reproduce using b44a681 but not 5040a26. Looks like #375 has already fixed this. @amantoux Could you please verify so that we can close the issue? @maelchiotti

maelchiotti commented 1 month ago

Sure I'll check tomorrow.

amantoux commented 1 month ago

🤔 I think I was able to reproduce at head

amantoux commented 1 month ago

I gave it another try this morning, but couldn't reproduce at https://github.com/fleather-editor/fleather/commit/b44a68159584ca40c74493589ed1cfbf312993eb nor at https://github.com/fleather-editor/fleather/commit/5040a269b86b250fc3b131023ffc78d102479ec3 nor at 1b4bbbfd17086826b8b56845a2ad568b1da3b48d.

I'm not sure this is fixed with #375, unless you have an explanation @Amir-P

maelchiotti commented 1 month ago

I can still reproduce with 1.16.0 but not with 1.17.0, so for me this is fixed indeed. Don't know what is happening to you @amantoux 😅

amantoux commented 1 month ago

I can still reproduce with 1.16.0 but not with 1.17.0, so for me this is fixed indeed. Don't know what is happening to you @amantoux 😅

Fine by me, closing this then

Amir-P commented 1 month ago

I gave it another try this morning, but couldn't reproduce at https://github.com/fleather-editor/fleather/commit/b44a68159584ca40c74493589ed1cfbf312993eb nor at https://github.com/fleather-editor/fleather/commit/5040a269b86b250fc3b131023ffc78d102479ec3 nor at 1b4bbbfd17086826b8b56845a2ad568b1da3b48d.

I'm not sure this is fixed with #375, unless you have an explanation @Amir-P

No explanations yet but I was able to consistently reproduce with head before 5040a26.