Repository navigation
[Testing] containsSemantics can't find semanticsLabel inside FormField #173838
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33found in release: 3.35Found to occur in 3.35Found to occur in 3.35frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility teamTriaged by Framework Accessibility team
Description
Steps to reproduce
Start the two example tests.
The first one failes, the second one is successfully.
Expected results
Both tests should work.
Actual results
The first test can't find the semantics from the semantics tree, because it is wrapped inside a FormField Widget.
It was working with Flutter 3.29.x, but is broken since Flutter 3.32.x.
Also broken with 3.35.1 and master channel.
Code sample
Example app
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: Scaffold(
body: Column(
children: [
Semantics(
label: 'first parent semantics label',
explicitChildNodes: true,
child: FormField(
builder: (field) => Semantics(label: 'failing child semantics label', child: Container(height: 40)),
),
),
Semantics(
label: 'second parent semantics label',
explicitChildNodes: true,
child: Semantics(label: 'successful child semantics label', child: Container(height: 40)),
),
],
),
),
);
}
}
Example test
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:semantics/main.dart';
void main() {
testWidgets('semantics broken', (WidgetTester tester) async {
await tester.pumpWidget(const MyApp());
debugDumpSemanticsTree();
expect(
tester.semantics.simulatedAccessibilityTraversal(),
containsOnce(containsSemantics(label: 'failing child semantics label')),
);
});
testWidgets('semantics successfully', (WidgetTester tester) async {
await tester.pumpWidget(const MyApp());
debugDumpSemanticsTree();
expect(
tester.semantics.simulatedAccessibilityTraversal(),
containsOnce(containsSemantics(label: 'successful child semantics label')),
);
});
}
Screenshots or Video
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[Paste your output here]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33found in release: 3.35Found to occur in 3.35Found to occur in 3.35frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility teamTriaged by Framework Accessibility team
Activity
tirth-patel-nc commentedon Aug 15, 2025
Thanks for the report. Seeing the same behaviour with latest SDK versions. First test fails on following versions:
might be related to #165363
Error - flutter test log
However both tests passes on
3.29.3. Marking it as a regression.3.29.3 - flutter test log
Bisected to #165935
Bisect Log
8 remaining items
flutter-triage-bot commentedon Aug 27, 2025
The
triaged-frameworklabel is irrelevant if there is noteam-frameworklabel orfyi-frameworklabel.chunhtai commentedon Aug 27, 2025
I think something probably got dropped during the semantics merging. Do you have a semantics tree dump to verify if the label is still in the tree?
yjbanov commentedon Aug 27, 2025
FYI, the output of
debugDumpSemanticsTreedoes contain the node:hannah-hyj commentedon Aug 27, 2025
i can take a look at this one
hannah-hyj commentedon Aug 27, 2025
looks like it is relate to SemanticsValidationResult
For the formfield node, if we change
to
The test will pass.
We need to
update containsSemantics to not check validationResult if it passes a null,
improve the semantics tree dump, so the semantics tree will also show SemanticsValidationResult
[a11y] [test] containsSemantics can ignore SemanticsValidationResult (#…
Include SemanticsValidationResult in debugDumpSemanticsTree (#174677)
github-actions commentedon Sep 12, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.