joanpablo / reactive_forms

This is a model-driven approach to handling form inputs and validations, heavily inspired in Angular's Reactive Forms
MIT License
469 stars 86 forks source link

Autofocus a ReactiveDropdownField #463

Open AdrienLemaire opened 1 month ago

AdrienLemaire commented 1 month ago

Environment

Package version: 17.0.1

Describe your question

How can I get a dropdown list to show up by default when landing on a form ?

UsamaKarim commented 2 weeks ago

I tried and it doesn't seems to be working for me.

Here's my implementation

onEditingComplete: (_) {
    final control = form.control('account_type')
        as FormControl<AccountType>;
    final focusNode = control.focusController?.focusNode;
    final fnContext = focusNode?.context;
    if (fnContext != null) {
      focusNode?.requestFocus();
      Scrollable.ensureVisible(fnContext);
    }
  },