Skip to content

Autocomplete blocks keyboard navigation using TAB #183456

Closed

Description

@mlizee-epsilia

Steps to reproduce

Hello!

When using the Autocomplete widget, the keyboard navigation using TAB is sometimes blocked. It seems to only be an issue if the next widget is disabled.

Here's the Flutter version I use:
Flutter 3.41.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision ff37bef603 (7 days ago) • 2026-03-03 16:03:22 -0800 Engine • hash 99578ad0355da00edb26301c874a3c250a5716f5 (revision e4b8dca3f1) (6 days ago) • 2026-03-03 18:24:54.000Z Tools • Dart 3.11.1 • DevTools 2.54.1

Expected results

The expected behavior appears only when the next widget is enabled. Pressing TAB should navigate to the next enabled widget:

Image

Actual results

The issue seems to only appear when the next widget is disabled. In this case, pressing TAB does not navigate to the next enabled widget; the user is stucked inside the autocomplete:

Image

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class MeasuringUnitDTO {
  MeasuringUnitDTO({required this.id, this.description});

  String id;
  String? description;
}

class UnitsOfMeasureAutocomplete extends StatelessWidget {
  const UnitsOfMeasureAutocomplete({
    super.key,
    required this.unitOfMeasureCode,
    this.onSelectionChanged,
  });

  final String? unitOfMeasureCode;
  final void Function(MeasuringUnitDTO?)? onSelectionChanged;

  @override
  Widget build(BuildContext context) {
    final unitsOfMeasure = [
      MeasuringUnitDTO(id: 'KG', description: 'Kilogram'),
      MeasuringUnitDTO(id: 'L', description: 'Liter'),
      MeasuringUnitDTO(id: 'M', description: 'Meter'),
      MeasuringUnitDTO(id: 'PCS', description: 'Pieces'),
      MeasuringUnitDTO(id: 'BOX', description: 'Box'),
    ];

    return Autocomplete<MeasuringUnitDTO>(
      displayStringForOption: (option) => option.id,
      onSelected: (selectedOption) => onSelectionChanged?.call(selectedOption),
      optionsBuilder: (textEditingValue) => unitsOfMeasure.where((option) {
        final searchLower = textEditingValue.text.toLowerCase();
        return searchLower.isEmpty ||
            option.id.toLowerCase().contains(searchLower) ||
            (option.description?.toLowerCase().contains(searchLower) ?? false);
      }),
    );
  }
}

void main() {
  runApp(const MainApp());
}

class MainApp extends HookWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    final firstUnitOfMeasure = useState<String?>(null);
    final secondUnitOfMeasure = useState<String?>(null);

    return MaterialApp(
      home: Scaffold(
        body: Column(
          spacing: 16,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              spacing: 8,
              children: [
                Expanded(child: TextFormField()),
                Expanded(
                  child: UnitsOfMeasureAutocomplete(
                    unitOfMeasureCode: firstUnitOfMeasure.value,
                    onSelectionChanged: (value) {
                      firstUnitOfMeasure.value = value?.id;
                    },
                  ),
                ),
              ],
            ),
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              spacing: 8,
              children: [
                Expanded(
                  child: TextFormField(
                    // TODO: Set as true to make the keyboard navigation work
                    enabled: false,
                  ),
                ),
                Expanded(child: TextFormField(enabled: false)),
              ],
            ),
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              spacing: 8,
              children: [
                Expanded(child: TextFormField(enabled: false)),
                Expanded(
                  child: UnitsOfMeasureAutocomplete(
                    unitOfMeasureCode: secondUnitOfMeasure.value,
                    onSelectionChanged: (value) {
                      secondUnitOfMeasure.value = value?.id;
                    },
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Logs

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.41.4, on Microsoft Windows [Version 10.0.26200.7840], locale en-CA)
[✓] Windows Version (11 Business 64-bit, 25H2, 2009)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.14.27 (February 2026))
[✓] Connected device (3 available)
[✓] Network resources

Activity

  1. antonio-pedro99 commented on Mar 10, 2026

    @antonio-pedro99

    Hey @mlizee-epsilia, what about publising the "small code" as a gist? or maybe inlined code support of markdown. Something like

    void main() {
      print("Your code");
    }
  2. mlizee-epsilia commented on Mar 11, 2026

    @mlizee-epsilia
    Author

    Hello @antonio-pedro99 ! I have included the code in the bug description

  3. victorsanni commented on Mar 12, 2026

    @victorsanni
    Contributor
  4. added
    in triage
    on Mar 13, 2026
  5. saurabh-mirajkar commented on Mar 13, 2026

    @saurabh-mirajkar
    Contributor

    @mlizee-epsilia Thanks for the detailed report and reproduction. I can confirm that I am able to replicate the issue on macOS 26.3.1. Since this affects keyboard navigation within the framework widgets layer, I am labeling this for the framework team to investigate further.

  6. added
    framework
    p: material_ui
    team-framework
    a: accessibility
    and removed
    in triage
    on Mar 13, 2026
  7. added
    team-text-input
    c: regression
    and removed
    team-framework
    on Mar 17, 2026
  8. Piinks commented on Mar 17, 2026

    @Piinks
    Contributor

    Re-routing the text input team.

  9. added
    P2
    triaged-text-input
    on Mar 19, 2026
  10. github-actions commented on May 20, 2026

    @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.

  11. locked as resolved and limited conversation to collaborators on May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: accessibilityc: regressionframeworkp: material_uiteam-text-inputtriaged-text-input

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions