@@ -9,11 +9,19 @@ import '../util.dart';
99/// Provides accessibility for dialogs.
1010///
1111/// See also [Role.dialog] .
12- class Dialog extends RoleManager {
13- Dialog (SemanticsObject semanticsObject) : super (Role .dialog, semanticsObject);
12+ class Dialog extends PrimaryRoleManager {
13+ Dialog (SemanticsObject semanticsObject) : super .blank (PrimaryRole .dialog, semanticsObject) {
14+ // The following secondary roles can coexist with dialog. Generic `RouteName`
15+ // and `LabelAndValue` are not used by this role because when the dialog
16+ // names its own route an `aria-label` is used instead of `aria-describedby`.
17+ addFocusManagement ();
18+ addLiveRegion ();
19+ }
1420
1521 @override
1622 void update () {
23+ super .update ();
24+
1725 // If semantic object corresponding to the dialog also provides the label
1826 // for itself it is applied as `aria-label`. See also [describeBy].
1927 if (semanticsObject.namesRoute) {
@@ -31,7 +39,7 @@ class Dialog extends RoleManager {
3139 return true ;
3240 }());
3341 semanticsObject.element.setAttribute ('aria-label' , label ?? '' );
34- semanticsObject.setAriaRole ('dialog' , true );
42+ semanticsObject.setAriaRole ('dialog' );
3543 }
3644 }
3745
@@ -43,7 +51,7 @@ class Dialog extends RoleManager {
4351 return ;
4452 }
4553
46- semanticsObject.setAriaRole ('dialog' , true );
54+ semanticsObject.setAriaRole ('dialog' );
4755 semanticsObject.element.setAttribute (
4856 'aria-describedby' ,
4957 routeName.semanticsObject.element.id,
@@ -88,11 +96,11 @@ class RouteName extends RoleManager {
8896
8997 void _lookUpNearestAncestorDialog () {
9098 SemanticsObject ? parent = semanticsObject.parent;
91- while (parent != null && ! parent.hasRole ( Role . dialog) ) {
99+ while (parent != null && parent.primaryRole ? .role != PrimaryRole . dialog) {
92100 parent = parent.parent;
93101 }
94- if (parent != null && parent.hasRole ( Role . dialog) ) {
95- _dialog = parent.getRole < Dialog >( Role .dialog) ;
102+ if (parent != null && parent.primaryRole ? .role == PrimaryRole . dialog) {
103+ _dialog = parent.primaryRole ! as Dialog ;
96104 }
97105 }
98106}
0 commit comments