Skip to content

MenuItemButton shows an incorrect shortcut for CharacterActivators with modifier keys. #145040

@Caffeinix

Description

@Caffeinix

Steps to reproduce

  1. Create a MenuItemButton whose shortcut is a CharacterActivator with at least one modifier set (control, meta, alt, etc).
  2. Render your MenuItemButton.

Expected results

The MenuItemButton shortcut should include the modifier keys needed to activate the shortcut.

Actual results

the MenuItemButton's shortcut is rendered as the character you selected for your CharacterActivator, without any of the modifiers you specified. Typing that character alone will not activate the menu item (the CharacterActivator itself is correct), so the shortcut shown in the menu button is wrong.

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    final examples = [
      (
        SingleActivator(LogicalKeyboardKey.keyS, control: true),
        Text('SingleActivator'),
      ),
      (
        CharacterActivator('S', control: true),
        Text('CharacterActivator'),
      ),
    ];

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              for (final (shortcut, child) in examples)
                SizedBox(
                  width: 200,
                  child: MenuItemButton(shortcut: shortcut, child: child),
                ),
            ],
          ),
        ),
      ),
    );
  }
}

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

Labels

P2Important issues not at the top of the work listcustomer: googleVarious Google teamsf: material designflutter/packages/flutter/material repository.found in release: 3.19Found to occur in 3.19found in release: 3.21Found to occur in 3.21frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions