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

[Bug]: Autocomplete onChanged does not work #284

Open
2 tasks done
damian-hug opened this issue Feb 26, 2025 · 1 comment
Open
2 tasks done

[Bug]: Autocomplete onChanged does not work #284

damian-hug opened this issue Feb 26, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@damian-hug
Copy link

Preflight Checklist

Bug type

Functionality

Which release are you using?

2.2.0

Flutter SDK version

3.22.0

Additional settings

No response

Expected

If a character is typed into the text field, the onChanged method should get executed.

What happened?

If a character is typed into the text field, the onChanged method does not execute. This is crucial if you want to generate suggestions dynamically based on the input of the autocomplete text field

Steps to reproduce the issue

  1. Type a character into the autocomplete text field
  2. See how the onChanged method doesn't get hit

Relevant log output

@damian-hug damian-hug added the bug Something isn't working label Feb 26, 2025
@damian-hug
Copy link
Author

There is a workaround (dirty and untested but it works in my specific case fine).

_textField = SBBTextField(
      controller: widget.controller ?? TextEditingController(),
      enabled: widget.enabled,
      enableInteractiveSelection: widget.enableInteractiveSelection,
      hintText: widget.hintText,
      inputFormatters: widget.inputFormatters,
      isLastElement: widget.isLastElement,
      keyboardType: widget.keyboardType,
      labelText: widget.labelText,
      onChanged: (newText) {
        _currentText = newText;
        showOverlay = true;
        _updateOverlay(query: newText);

        // Add the manual onChanged callback to the widget
        widget.onChanged?.call(newText);
      },
      onTap: () {
        showOverlay = true;
        _updateOverlay(query: _currentText);
      },
      onSubmitted: (submittedText) {
        triggerSubmitted(submittedText);
      },
      textCapitalization: widget.textCapitalization,
      icon: widget.icon,
      focusNode: widget.focusNode ?? FocusNode(),
    );

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
Status: Funnel
Development

No branches or pull requests

1 participant