Skip to content

DropdownMenu doesn't fire onSelected from keyboard navigation #143505

@Hixie

Description

@Hixie

STEPS TO REPRODUCE

  1. Run the program below.
  2. Tab until the dropdown menu is focused. (Side note: this seems to take an inordinate number of tabs given that there's only two focusable controls on the screen, but that's another bug.)
  3. Press enter to open the menu.
  4. Hit down arrow to highlight "Foo.aa".
  5. Press enter to select "Foo.aa".

EXPECTED RESULTS

Selected value becomes "Foo.aa".

ACTUAL RESULTS

Selected value remains "null".

CODE FOR TEST PROGRAM

import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: MyHomePage()));
}

enum Foo { aa, bb, cc }

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Foo? _value;

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Column(
        children: [
          Text('Selected value: $_value'),
          DropdownMenu<Foo>(
            onSelected: (Foo? value) {
              setState(() {
                _value = value;
              });
            },
            dropdownMenuEntries: Foo.values
                .map<DropdownMenuEntry<Foo>>(
                  (Foo f) => DropdownMenuEntry(value: f, label: '$f'),
                )
                .toList(),
          ),
        ],
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)f: focusFocus traversal, gaining or losing focusf: material designflutter/packages/flutter/material repository.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions