Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusp: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
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')),
),
),
),
],
),
),
);
}
}
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusp: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
visma-onnimanni-hannonen commentedon May 30, 2025
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.