File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -242,23 +242,29 @@ class SemanticsController {
242
242
/// * [flutter/engine/AccessibilityBridge.java#SemanticsNode.isFocusable()] (https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/view/AccessibilityBridge.java#L2641)
243
243
/// * [flutter/engine/SemanticsObject.mm#SemanticsObject.isAccessibilityElement] (https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm#L449)
244
244
bool _isImportantForAccessibility (SemanticsNode node) {
245
+ if (node.isMergedIntoParent) {
246
+ // If this node is merged, all its information are present on an ancestor
247
+ // node.
248
+ return false ;
249
+ }
250
+ final SemanticsData data = node.getSemanticsData ();
245
251
// If the node scopes a route, it doesn't matter what other flags/actions it
246
252
// has, it is _not_ important for accessibility, so we short circuit.
247
- if (node .hasFlag (SemanticsFlag .scopesRoute)) {
253
+ if (data .hasFlag (SemanticsFlag .scopesRoute)) {
248
254
return false ;
249
255
}
250
256
251
- final bool hasNonScrollingAction = node. getSemanticsData () .actions & ~ _scrollingActions != 0 ;
257
+ final bool hasNonScrollingAction = data .actions & ~ _scrollingActions != 0 ;
252
258
if (hasNonScrollingAction) {
253
259
return true ;
254
260
}
255
261
256
- final bool hasImportantFlag = node. getSemanticsData () .flags & _importantFlagsForAccessibility != 0 ;
262
+ final bool hasImportantFlag = data .flags & _importantFlagsForAccessibility != 0 ;
257
263
if (hasImportantFlag) {
258
264
return true ;
259
265
}
260
266
261
- final bool hasContent = node .label.isNotEmpty || node .value.isNotEmpty || node .hint.isNotEmpty;
267
+ final bool hasContent = data .label.isNotEmpty || data .value.isNotEmpty || data .hint.isNotEmpty;
262
268
if (hasContent) {
263
269
return true ;
264
270
}
Original file line number Diff line number Diff line change @@ -982,6 +982,38 @@ void main() {
982
982
tester.semantics.simulatedAccessibilityTraversal (),
983
983
containsAllInOrder (expectedMatchers));
984
984
});
985
+
986
+ testWidgets ('merging node should not be visited' , (WidgetTester tester) async {
987
+ await tester.pumpWidget (
988
+ MaterialApp (
989
+ home: MergeSemantics (
990
+ child: Column (
991
+ children: < Widget > [
992
+ Semantics (
993
+ container: true ,
994
+ child: const Text ('1' ),
995
+ ),
996
+ Semantics (
997
+ container: true ,
998
+ child: const Text ('2' ),
999
+ ),
1000
+ Semantics (
1001
+ container: true ,
1002
+ child: const Text ('3' ),
1003
+ ),
1004
+ ],
1005
+ ),
1006
+ ),
1007
+ ),
1008
+ );
1009
+
1010
+ expect (
1011
+ tester.semantics.simulatedAccessibilityTraversal (),
1012
+ orderedEquals (
1013
+ < Matcher > [containsSemantics (label: '1\n 2\n 3' )],
1014
+ ),
1015
+ );
1016
+ });
985
1017
});
986
1018
});
987
1019
}
You can’t perform that action at this time.
0 commit comments