Skip to content

CupertinoContextMenuAction: Add focus support #167114

Open

Description

@O-Hannonen

Use case

CupertinoContextMenuAction is not able to receive focus so CupertinoContextMenu can't be navigated with keyboard when it has CupertinoContextMenuActions as children.

Found while implementing fixes for #166398 and #165977, so highly related to those.

Proposal

The native iOS context menu components work with keyboard like so:
https://github.com/user-attachments/assets/4d6891bb-c947-4730-9e3f-3e952dc3276a

Here is a reproducible example of how this does not work in Flutter.

Example
import 'package:flutter/cupertino.dart';
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(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,

        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          spacing: 16,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CupertinoContextMenu(
              actions: <Widget>[
                CupertinoContextMenuAction(
                  child: Text('Action 1'),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
                CupertinoContextMenuAction(
                  child: Text('Action 2'),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
                CupertinoContextMenuAction(
                  isDestructiveAction: true,
                  child: Text('Delete'),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
              ],
              child: Material(
                child: Container(
                  width: 100,
                  height: 100,
                  color: Colors.blue,
                  child: Center(child: Text('Hold me')),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: cupertino_uicupertino_ui package in flutter/packages
    c: proposalA detailed proposal for a change to Flutter
    f: focusFocus traversal, gaining or losing focus
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Apr 15, 2025
  2. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Apr 23, 2025
  3. visma-onnimanni-hannonen commented on May 30, 2025

    @visma-onnimanni-hannonen

    Just a small status update here too: I've started working on this and most of the changes are already done, but the rest are pending on the changes from this PR.

  4. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 18, 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

    P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterf: focusFocus traversal, gaining or losing focusp: cupertino_uicupertino_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-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