flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

[FormBuilderCheckbox]: Focus bug

Open geronimol opened this issue 5 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Package/Plugin version

10.0.0

Platforms

  • [ ] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] MacOS
  • [x] Web
  • [ ] Windows

Flutter doctor

Flutter doctor
[✓] Flutter (Channel stable, 3.32.2, on macOS 15.5 24F74 darwin-x64, locale es-AR) [2,6s]
    • Flutter version 3.32.2 on channel stable at /usr/local/Caskroom/flutter/3.32.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8defaa71a7 (3 weeks ago), 2025-06-04 11:02:51 -0700
    • Engine revision 1091508939
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [6,7s]
    • Android SDK at /Users/gero/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [4,1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [41ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [40ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.101.0) [37ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available) [9,4s]
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.5 24F74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 137.0.7151.120

[✓] Network resources [1.388ms]
    • All expected network resources are available.

• No issues found!

Minimal code example

Code sample
class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final formKey = GlobalKey<FormBuilderState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          FormBuilder(
            key: formKey,
            child: Column(
              children: [
                FormBuilderTextField(name: 'text', onChanged: (v) => formKey.currentState?.fields['checkbox']?.didChange(true)),
                FormBuilderCheckbox(name: 'checkbox', title: const Text('Checkbox')),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

Current Behavior

Calling didChange() focuses the checkbox(and lost focus if you were using the text field)

Expected Behavior

This is what was happening in the previous version: Calling didChange() doesn't focus the checkbox(and keep focusing the text field if you were using it)

Is there a new way to keep this behavior? Or is this a bug?

Steps To Reproduce

Type something in the text field, so didChange will be triggered

Aditional information

No response

geronimol avatar Jun 23 '25 17:06 geronimol