Skip to content

web: GestureDetector with Semantics service enabled causes the onTap callback to be called twice #153924

@pedromassango

Description

@pedromassango

Steps to reproduce

  1. Run the sample code
  2. Tap ONCE on the button

Expected results

The on tap callback is called twice:

onTap
onTap

Actual results

The on tap callback must be called once:

onTap

Code sample

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SemanticsBinding.instance.ensureSemantics();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Semantics(
        // this causes the callback to be called twice
        enabled: true,
        child: Scaffold(
          body: Center(
            child: GestureDetector(
              onTap: () => print('onTap'),
              child: const Text('Click me'),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Flutter (Channel stable, 3.24.1, on macOS 14.5 23F79 darwin-arm64,
    locale en-DE)
    • Flutter version 3.24.1 on channel stable at
      /Users/pedromassango/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (2 days ago), 2024-08-20 16:46:00
      -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[!] Android toolchain - develop for Android devices (Android SDK
    version 34.0.0)
    • Android SDK at /Users/pedromassango/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more
      details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK
      licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is
      necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch
        /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see
      https://guides.cocoapods.org/using/getting-started.html#installa
      tion

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/pedromassango/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
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.2)
    • IntelliJ at /Users/pedromassango/Applications/IntelliJ IDEA
      Ultimate.app
    • Flutter plugin version 80.0.2
    • Dart plugin version 242.20629

[✓] IntelliJ IDEA Community Edition (version 2024.1.6)
    • IntelliJ at /Users/pedromassango/Applications/IntelliJ IDEA
      Community Edition.app
    • Flutter plugin version 81.0.2
    • Dart plugin version 241.18968.26

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.5 23F79
      darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome
      127.0.6533.120

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

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)found in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions