From 3d4fd550c2b5c4bb879319fe050827cf656f8fc9 Mon Sep 17 00:00:00 2001
From: "auto-submit[bot]" <98614782+auto-submit[bot]@users.noreply.github.com>
Date: Thu, 30 May 2024 17:43:26 +0000
Subject: [PATCH] Reverts "Enable `explicitChildNodes` for the `AlertDialog`
content (#149130)" (#149333)
Reverts: flutter/flutter#149130
Initiated by: Piinks
Reason for reverting: Google testing did not run on this PR and multiple semantics screen shots from internal testing look incorrect.
Original PR Author: TahaTesser
Reviewed By: {goderbauer}
This change reverts the following previous change:
fixes [AlertDialog content semantics merged](https://github.com/flutter/flutter/issues/147574)
### Code sample
expand to view the code sample
```dart
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(
debugShowCheckedModeBanner: false,
// showSemanticsDebugger: true,
home: Scaffold(
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Some text'),
Text('More text'),
],
),
Builder(builder: (BuildContext context) {
return ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Dialog Title'),
content: const Column(
children: [
Text('Some text'),
Text('More text'),
],
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Close'),
),
],
);
},
);
},
child: const Text('Open Dialog'),
);
}),
],
),
),
),
),
);
}
}
```
### Before vs After


---
packages/flutter/lib/src/material/dialog.dart | 1 -
.../flutter/test/material/dialog_test.dart | 23 ++++---------------
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart
index 09ac978cef..e8049dfdba 100644
--- a/packages/flutter/lib/src/material/dialog.dart
+++ b/packages/flutter/lib/src/material/dialog.dart
@@ -812,7 +812,6 @@ class AlertDialog extends StatelessWidget {
style: contentTextStyle ?? dialogTheme.contentTextStyle ?? defaults.contentTextStyle!,
child: Semantics(
container: true,
- explicitChildNodes: true,
child: content,
),
),
diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart
index ebc1af01fc..9415e58aae 100644
--- a/packages/flutter/test/material/dialog_test.dart
+++ b/packages/flutter/test/material/dialog_test.dart
@@ -1700,12 +1700,7 @@ void main() {
theme: ThemeData(platform: TargetPlatform.iOS),
home: const AlertDialog(
title: Text('title'),
- content: Column(
- children: [
- Text('some content'),
- Text('more content'),
- ],
- ),
+ content: Text('content'),
actions: [ TextButton(onPressed: null, child: Text('action')) ],
),
),
@@ -1736,21 +1731,11 @@ void main() {
// node 4.
TestSemantics(
id: 6,
- children: [
- TestSemantics(
- id: 7,
- label: 'some content',
- textDirection: TextDirection.ltr,
- ),
- TestSemantics(
- id: 8,
- label: 'more content',
- textDirection: TextDirection.ltr,
- ),
- ],
+ label: 'content',
+ textDirection: TextDirection.ltr,
),
TestSemantics(
- id: 9,
+ id: 7,
flags: [
SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState,