Unverified Commit 6cab3f60 authored by chunhtai's avatar chunhtai Committed by GitHub

fix simple dialog introducing additional node for semantics label (#68804)

* fix simple dialog introducing additional node for semantics label

* add test
parent dd2ea7c5
......@@ -841,7 +841,7 @@ class SimpleDialog extends StatelessWidget {
),
child: DefaultTextStyle(
style: titleTextStyle ?? DialogTheme.of(context).titleTextStyle ?? theme.textTheme.headline6!,
child: Semantics(namesRoute: true, child: title),
child: Semantics(namesRoute: label == null, child: title),
),
);
}
......@@ -879,6 +879,8 @@ class SimpleDialog extends StatelessWidget {
if (label != null)
dialogChild = Semantics(
scopesRoute: true,
explicitChildNodes: true,
namesRoute: true,
label: label,
child: dialogChild,
......
......@@ -1377,6 +1377,48 @@ void main() {
semantics.dispose();
});
testWidgets('SimpleDialog does not introduce additional node', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Material(
child: Builder(
builder: (BuildContext context) {
return Center(
child: ElevatedButton(
child: const Text('X'),
onPressed: () {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return const SimpleDialog(
title: Text('Title'),
semanticLabel: 'label',
);
},
);
},
),
);
},
),
),
),
);
await tester.tap(find.text('X'));
await tester.pumpAndSettle();
// A scope route is not focusable in accessibility service.
expect(semantics, includesNodeWith(
label: 'label',
flags: <SemanticsFlag>[SemanticsFlag.namesRoute, SemanticsFlag.scopesRoute],
));
semantics.dispose();
});
testWidgets('Dismissible.confirmDismiss defers to an AlertDialog', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final List<int> dismissedItems = <int>[];
......
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