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

[FormBuilderSearchableDropdown] how to open dropdown programatically #104

Open
3 of 7 tasks
ronak-selldo opened this issue Feb 2, 2024 · 3 comments
Open
3 of 7 tasks
Labels
bug Something isn't working

Comments

@ronak-selldo
Copy link

ronak-selldo commented Feb 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

8.3.0

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

Flutter doctor

Flutter doctor
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.5.2 22G91 darwin-arm, locale en-IN)
    • Flutter version 3.3.10 on channel stable at /Applications/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (1 year, 2 months ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/ronakkalavadia/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.14.3

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

[!] Android Studio (version 2023.1)
    • 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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] Connected device (3 available)
    • iPhone 15 (mobile) • F0CD531E-982B-4CDC-B593-9E974CB747C1 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 121.0.6167.139
    ! Error: Browsing on the local area network for RK iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone SE Old. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.

Minimal code example

Code sample
final _focusNode = FocusNode();

@override
  void initState() {
    afterBuild(() {
          _focusNode.requestFocus();
    });
    super.initState();
  }

return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        ValueListenableBuilder(
            valueListenable: widget.field,
            builder: (context, dynamic value, _) {
              return FormBuilderSearchableDropdown<String>(
                key: ValueKey(value),
                focusNode: _focusNode,
                name: widget.field.internalName!,
                items: const ["Brazil", "France", "Tunisia", "Canada"],
                compareFn:
                    (String existingSelectedValue, String valueToBeRemoved) =>
                        existingSelectedValue == valueToBeRemoved,
              );
            }),
      ],
    );

Current Behavior

Dropdown is not opening with focusNode.

Expected Behavior

Dropdown should open with focus node.

Steps To Reproduce

  1. Set focus node of FormBuilderSearchableDropdown.
  2. Then set focusNode.requestFocus(); in init function.
  3. Dropdown not opening automatically.

Aditional information

No response

@ronak-selldo ronak-selldo added the bug Something isn't working label Feb 2, 2024
@deandreamatias
Copy link
Contributor

Hi!
This works using directly the package https://pub.dev/packages/dropdown_search?
Also, add a minimal executable code example. Thanks

@ronak-selldo
Copy link
Author

I think there is no focusNode available in this package.

DropdownSearch({
Key? key,
this.onSaved,
this.validator,
this.autoValidateMode = AutovalidateMode.disabled,
this.onChanged,
this.items = const [],
this.selectedItem,
this.asyncItems,
this.dropdownBuilder,
this.dropdownDecoratorProps = const DropDownDecoratorProps(),
this.clearButtonProps = const ClearButtonProps(),
this.dropdownButtonProps = const DropdownButtonProps(),
this.enabled = true,
this.filterFn,
this.itemAsString,
this.compareFn,
this.onBeforeChange,
this.onBeforePopupOpening,
PopupProps popupProps = const PopupProps.menu(),
})

@ronak-selldo
Copy link
Author

Minimal code sample.

final _focusNode = FocusNode();

@override
  void initState() {
    afterBuild(() {
          _focusNode.requestFocus();
    });
    super.initState();
  }

return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        ValueListenableBuilder(
            valueListenable: widget.field,
            builder: (context, dynamic value, _) {
              return FormBuilderSearchableDropdown<String>(
                key: ValueKey(value),
                focusNode: _focusNode,
                name: widget.field.internalName!,
                items: const ["Brazil", "France", "Tunisia", "Canada"],
                compareFn:
                    (String existingSelectedValue, String valueToBeRemoved) =>
                        existingSelectedValue == valueToBeRemoved,
              );
            }),
      ],
    );

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