Skip to content

Autocomplete does not dismiss overlay on selection #99749

Closed

Description

@StraussPorcupine

The bug happens when you use autocomplete, and the user fills in the same value as what is recommended and the user clicks on the recommended value, if it is the same as the filled value, it will not dismiss the overlay.

Steps to Reproduce

This bug is on any Autocomplete widget
Even on the Api.flutter.dev

  1. Go to https://api.flutter.dev/flutter/material/Autocomplete-class.html
  2. Run the first example.
  3. in the input field type in 'aardvark'
  4. click on the recommended answer that is the same

Expected results:
The expected result is the overlay to dismiss.

Actual results:
Overlay stays, and nothing happens, the material splash happens, but it does not close the overlay.

Activity

  1. maheshj01 commented on Mar 8, 2022

    @maheshj01
    Member

    Hi @StraussPorcupine, Thanks for filing the issue. I am able to reproduce the issue on stable and the master channel. Basically, this issue occurs if the AutoCompleteField contains exactly one of the options in the list then the options cannot be submitted.

    code sample
    import 'package:flutter/material.dart';
    
    void main() => runApp(const AutocompleteExampleApp());
    
    class AutocompleteExampleApp extends StatelessWidget {
      const AutocompleteExampleApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Autocomplete Basic'),
            ),
            body: const Center(
              child: AutocompleteBasicExample(),
            ),
          ),
        );
      }
    }
    
    class AutocompleteBasicExample extends StatelessWidget {
      const AutocompleteBasicExample({Key? key}) : super(key: key);
    
      static const List<String> _kOptions = <String>[
        'aardvark',
        'bobcat',
        'chameleon',
      ];
    
      @override
      Widget build(BuildContext context) {
        return Autocomplete<String>(
          optionsBuilder: (TextEditingValue textEditingValue) {
            if (textEditingValue.text == '') {
              return const Iterable<String>.empty();
            }
            return _kOptions.where((String option) {
              return option.contains(textEditingValue.text.toLowerCase());
            });
          },
          onSelected: (String selection) {
            debugPrint('You just selected $selection');
          },
        );
      }
    }
    
    flutter doctor -v (mac)
    [✓] Flutter (Channel stable, 2.10.3, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.10.3 at /Users/mahesh/Documents/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7e9793dee1 (20 hours ago), 2022-03-02 11:23:12 -0600
        • Engine revision bd539267b4
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • 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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.36.0
    
    [✓] Connected device (3 available)
        • Redmi K20 Pro (mobile) • 192.168.1.5:5555 • android-arm64  • Android 11 (API 30)
        • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome           • web-javascript • Google Chrome 99.0.4844.51
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel master, 2.11.0-0.0.pre.715, on macOS 12.1 21C52 darwin-arm, locale en-GB)
        • Flutter version 2.11.0-0.0.pre.715 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 8b95cd6f35 (7 hours ago), 2022-02-28 16:31:12 -0800
        • Engine revision 615a60512c
        • Dart version 2.17.0 (build 2.17.0-150.0.dev)
        • DevTools version 2.11.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! CocoaPods 1.10.2 out of date (1.11.0 is recommended).
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on
            the Dart side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • 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 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.34.0
    
    [✓] Connected device (4 available)
        • Redmi K20 Pro (mobile) • 192.168.1.2:5555                     • android-arm64  • Android 11 (API 30)
        • iPhone 13 Pro (mobile) • CBEF6BFA-D3DC-4680-8900-E01C62A4B04C • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.1 21C52 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 98.0.4758.109
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
  2. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Mar 8, 2022
  3. added
    r: fixedIssue is closed as already fixed in a newer version
    on Mar 22, 2022
  4. github-actions commented on Apr 5, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

found in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions