Unverified Commit fd4d6d70 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Remove semantics node generated by ExcludeFocus (#56568)

parent 2d26cbb2
......@@ -997,6 +997,7 @@ class ExcludeFocus extends StatelessWidget {
return Focus(
canRequestFocus: false,
skipTraversal: true,
includeSemantics: false,
descendantsAreFocusable: !excluding,
child: child,
);
......
......@@ -8,6 +8,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/semantics.dart';
import 'semantics_tester.dart';
class TestFocus extends StatefulWidget {
const TestFocus({
Key key,
......@@ -1585,6 +1587,12 @@ void main() {
expect(containerNode.hasFocus, isFalse);
expect(unfocusableNode.hasFocus, isFalse);
});
testWidgets("Focus doesn't introduce a Semantics node when includeSemantics is false", (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(Focus(includeSemantics: false, child: Container()));
final TestSemantics expectedSemantics = TestSemantics.root();
expect(semantics, hasSemantics(expectedSemantics));
});
});
group(ExcludeFocus, () {
testWidgets("Descendants of ExcludeFocus aren't focusable.", (WidgetTester tester) async {
......@@ -1625,5 +1633,11 @@ void main() {
expect(containerNode.hasFocus, isFalse);
expect(unfocusableNode.hasFocus, isFalse);
});
testWidgets("ExcludeFocus doesn't introduce a Semantics node", (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(ExcludeFocus(child: Container()));
final TestSemantics expectedSemantics = TestSemantics.root();
expect(semantics, hasSemantics(expectedSemantics));
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment