fix simple dialog introducing additional node for semantics label (#68804)
* fix simple dialog introducing additional node for semantics label * add test
This commit is contained in:
parent
dd2ea7c503
commit
6cab3f6008
@ -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>[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user