Skip to content

MergeSemantics does not merge custom actions #166588

@JetA2

Description

@JetA2

Steps to reproduce

Tested on iOS.

  1. Install the sample app.
  2. Inspect the app using Accessibility Inspector or test on device.

Expected results

The custom actions are available on the merged object.

Actual results

No custom actions are available on the merged object, or only the first custom action is available (happened once then could not reproduce).

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Title')),
        body: Center(child: MergeSemantics(child: (FirstWidget()))),
      ),
    );
  }
}

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

  static const firstAction = CustomSemanticsAction(label: 'First action');

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Semantics(
          label: 'First label',
          customSemanticsActions: {firstAction: () {}},
          child: Text('First widget'),
        ),
        SecondWidget(),
      ],
    );
  }
}

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

  static const secondAction = CustomSemanticsAction(label: 'Second action');

  @override
  Widget build(BuildContext context) {
    return Semantics(
      label: 'Second label',
      customSemanticsActions: {secondAction: () {}},
      child: Text('Second widget'),
    );
  }
}

Screenshots or Video

Image
Screenshots / Video demonstration

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.2, on macOS 14.7.4 23H420 darwin-arm64, locale en-GB) [1,972ms]
    • Flutter version 3.29.2 on channel stable at /Users/xxx/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (3 weeks 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 34.0.0) [2.1s]
    • Android SDK at /Users/xxx/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = /Users/xxx/Library/Android/sdk
    • 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 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,423ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2023.2) [13ms]
    • 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 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.99.0) [12ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] Connected device (5 available) [7.0s]
    • iPhone Q (wireless) (mobile)    • 00008130-001E58CC2608001C            • ios            • iOS 18.3.2 22D82
    • iPhone 16 Plus (mobile)         • CBF25661-246E-436A-AF05-031C6EE03BA0 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.7.4 23H420 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.7.4 23H420 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 135.0.7049.41
    ! Error: Browsing on the local area network for iPad Mini Q. Ensure the device is unlocked and attached with a cable or associated with the same
      local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)found in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions