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

🐛 AutoSuggestBox clear button does not work #238

Closed
Driky opened this issue Mar 24, 2022 · 3 comments · Fixed by #240
Closed

🐛 AutoSuggestBox clear button does not work #238

Driky opened this issue Mar 24, 2022 · 3 comments · Fixed by #240
Labels
bug Something isn't working

Comments

@Driky
Copy link

Driky commented Mar 24, 2022

Describe the bug
The AutoSuggestBox has the ability to display a clear button allowing for setting the TextController to empty and removing focus. When clicking the clear button the onPressed callback is never called.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://bdlukaa.github.io/fluent_ui/
  2. Click on the auto suggest box on the left side of the screen
  3. Select one of the suggested choice
  4. Click on the box to get focus
  5. Click on the newly appeared cleat button on the right of the field.
  6. Nothing happens.

Expected behavior
After step 5, the field is supposed to be cleared and the focus removed form it..

Additional context
I copied the code of the IconButton used to build the clear button. It works well on it's own. So the problem is localized inside the AutoSuggestBox widget itself.

Edit
To bypass the bug you can do the following:

autoSuggestBox: AutoSuggestBox(
          controller: _textController,
          items: const ['Item 1', 'Item 2', 'Item 3', 'Item 4'],
          clearButtonEnabled: false,
          trailingIcon: IconButton(
            icon: const Icon(FluentIcons.code),
            onPressed: () {
              print('onPressed');
              _textController.clear();
            },
          ),
        ),
@bdlukaa bdlukaa added the bug Something isn't working label Mar 24, 2022
@bdlukaa bdlukaa mentioned this issue Mar 24, 2022
3 tasks
@henry2man
Copy link
Contributor

@bdlukaa Although I have also had this issue I have seen another that may be related. When an element is chosen from the drop-down list, a change of type TextChangedReason.suggestionChosen is NOT being generated; instead TextChangedReason.userInput is always sent

@bdlukaa
Copy link
Owner

bdlukaa commented Mar 25, 2022

@henry2man why?

@henry2man
Copy link
Contributor

@henry2man why?

I don't know why 😆 But I saw you're working on the component so I wrote this, that's all.

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

Successfully merging a pull request may close this issue.

3 participants