Skip to content

SubmenuButton submenus close automatically only on first activation for non touchscreen events [Android] #154842

@franciscojma86

Description

@franciscojma86

Steps to reproduce

Create a SubmenuButton with a children menu items

  
                      SubmenuButton(
                        leadingIcon: Icon(Symbols.design_services),
                        menuChildren: [
                          MenuItemButton(
                            onPressed: () => print('Pressed'),
                            child: Text('My submenu item'),
                          ),
                        ],
                        child: Text('My submenu'),
                      ),

Tap on the Submenu button, and the My submenu item will flash open and close immediately. The submenu appears on tap down, and disappears on tap release. This only happens the first time. Any subsequent activations work fine.

Expected results

Tapping on the submenu will show the children and not disappear.

Actual results

Tapping on the submenu shows and hides the submenu on tap release.

Code sample

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MenuAnchor(
            builder: (context, controller, child) => TextButton(
              onPressed: () {
                controller.isOpen ? controller.close() : controller.open();
              },
              child: Text('Press here'),
            ),
            menuChildren: [
              SubmenuButton(menuChildren: [
                MenuItemButton(
                  onPressed: () {},
                  child: Text('Menu item'),
                ),
              ], child: Text('Submenu')),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: mouseIssues related to using a mouse or mouse supportcustomer: quake (g3)f: material designflutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24found in release: 3.25Found to occur in 3.25frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions