Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c9751c92
Unverified
Commit
c9751c92
authored
Sep 20, 2021
by
chunhtai
Committed by
GitHub
Sep 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes dialog title announce twice (#90075)
parent
5b7d671f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
63 deletions
+15
-63
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+15
-13
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+0
-50
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
c9751c92
...
...
@@ -499,7 +499,9 @@ class AlertDialog extends StatelessWidget {
child:
DefaultTextStyle
(
style:
titleTextStyle
??
dialogTheme
.
titleTextStyle
??
theme
.
textTheme
.
headline6
!,
child:
Semantics
(
namesRoute:
label
==
null
,
// For iOS platform, the focus always lands on the title.
// Set nameRoute to false to avoid title being announce twice.
namesRoute:
label
==
null
&&
theme
.
platform
!=
TargetPlatform
.
iOS
,
container:
true
,
child:
title
,
),
...
...
@@ -843,17 +845,15 @@ class SimpleDialog extends StatelessWidget {
final
ThemeData
theme
=
Theme
.
of
(
context
);
String
?
label
=
semanticLabel
;
if
(
title
==
null
)
{
switch
(
theme
.
platform
)
{
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
iOS
:
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
label
=
semanticLabel
??
MaterialLocalizations
.
of
(
context
).
dialogLabel
;
}
switch
(
theme
.
platform
)
{
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
iOS
:
break
;
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
label
??=
MaterialLocalizations
.
of
(
context
).
dialogLabel
;
}
// The paddingScaleFactor is used to adjust the padding of Dialog
...
...
@@ -874,7 +874,9 @@ class SimpleDialog extends StatelessWidget {
child:
DefaultTextStyle
(
style:
titleTextStyle
??
DialogTheme
.
of
(
context
).
titleTextStyle
??
theme
.
textTheme
.
headline6
!,
child:
Semantics
(
namesRoute:
label
==
null
,
// For iOS platform, the focus always lands on the title.
// Set nameRoute to false to avoid title being announce twice.
namesRoute:
label
==
null
&&
theme
.
platform
!=
TargetPlatform
.
iOS
,
container:
true
,
child:
title
,
),
...
...
packages/flutter/test/material/dialog_test.dart
View file @
c9751c92
...
...
@@ -1319,54 +1319,6 @@ void main() {
);
});
testWidgets
(
'AlertDialog widget contains route semantics from title for iOS'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
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
AlertDialog
(
title:
Text
(
'Title'
),
content:
Text
(
'Y'
),
actions:
<
Widget
>[],
);
},
);
},
),
);
},
),
),
),
);
expect
(
semantics
,
isNot
(
includesNodeWith
(
label:
'Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
)));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
expect
(
semantics
,
includesNodeWith
(
label:
'Title'
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
));
semantics
.
dispose
();
});
// Regression test for https://github.com/flutter/flutter/issues/78229.
testWidgets
(
'AlertDialog has correct semantics for content in iOS'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
...
...
@@ -1400,7 +1352,6 @@ void main() {
children:
<
TestSemantics
>[
TestSemantics
(
id:
5
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
label:
'title'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
@@ -1569,7 +1520,6 @@ void main() {
// node 4.
TestSemantics
(
id:
5
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
namesRoute
],
label:
'title'
,
textDirection:
TextDirection
.
ltr
,
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment