Skip to content

CupertinoContextMenu onTap gesture interferes with child widget with onTap GestureRecognizer #169911

@LorTos

Description

@LorTos

Steps to reproduce

  1. Tap on the widget for a bit longer than a "normal" tap, but not long enough to trigger the long press

Expected results

Either the CupertinoContextMenu long press animation completes, or the child widget's onTap is triggered and the animation is cancelled

Actual results

The child widget's onTap is triggered and the CupertinoContextMenu animation with the OverlayEntry remains

Code sample

Code sample
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) {
    final colorScheme = ColorScheme.fromSeed(seedColor: Colors.orange);
    return MaterialApp(
      theme: ThemeData(
        colorScheme: colorScheme,
        appBarTheme: AppBarTheme(backgroundColor: colorScheme.secondaryContainer),
      ),
      home: const HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: Text('Home'),
        ),
        body: Center(
          child: CupertinoContextMenu(
            actions: [
              CupertinoContextMenuAction(
                child: Text('Test'),
              ),
            ],
            child: GestureDetector(
              onTap: () {
                Navigator.of(context).push(
                  MaterialPageRoute(builder: (context) => _OtherPage()),
                );
              },
              child: Container(
                color: Colors.orange,
                height: 100,
                width: 100,
              ),
            ),
          ),
        ),
      );
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: Text('Other'),
        ),
      );
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-05-26.at.21.28.48.mov

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.5 24F74 darwin-arm64, locale en-IT) [408ms]
    • Flutter version 3.29.2 on channel stable at /Users/lortos/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (3 months ago), 2025-03-13 16:17:06 -0400
    • Engine revision 18b71d647a
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,695ms]
    • Android SDK at /Users/lortos/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [776ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [104ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [103ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)

[✓] IntelliJ IDEA Community Edition (version 2024.3.5) [102ms]
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 83.0.4
    • Dart plugin version 243.26053.17

[✓] VS Code (version 1.100.2) [10ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (4 available) [6.1s]
    • iPhone 16 Pro (mobile)            • 91805BB8-7975-444F-BF08-00324D08B649 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
    • macOS (desktop)                   • macos                                • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Mac Designed for iPad (desktop)   • mac-designed-for-ipad                • darwin         • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)                      • chrome                               • web-javascript • Google Chrome 137.0.7151.55

[✓] Network resources [681ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: cupertinoflutter/packages/flutter/cupertino repositoryf: gesturesflutter/packages/flutter/gestures repository.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions