diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/route.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/route.dart index 89052e6582..a7294d02f2 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/route.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/route.dart @@ -41,6 +41,13 @@ class SemanticRoute extends SemanticRole { // Case 2: nothing requested explicit focus. Focus on the first descendant. _setDefaultFocus(); }); + + // Lacking any more specific information, ARIA role "dialog" is the + // closest thing to Flutter's route. This can be revisited if better + // options become available, especially if the framework volunteers more + // specific information about the route. Other attributes in the vicinity + // of routes include: "alertdialog", `aria-modal`, "menu", "tooltip". + setAriaRole('dialog'); } void _setDefaultFocus() { @@ -79,7 +86,6 @@ class SemanticRoute extends SemanticRole { }()); setAttribute('aria-label', label ?? ''); - _assignRole(); } } @@ -91,22 +97,12 @@ class SemanticRoute extends SemanticRole { return; } - _assignRole(); setAttribute( 'aria-describedby', routeName.semanticsObject.element.id, ); } - void _assignRole() { - // Lacking any more specific information, ARIA role "dialog" is the - // closest thing to Flutter's route. This can be revisited if better - // options become available, especially if the framework volunteers more - // specific information about the route. Other attributes in the vicinity - // of routes include: "alertdialog", `aria-modal`, "menu", "tooltip". - setAriaRole('dialog'); - } - @override bool focusAsRouteDefault() { // Routes are the ones that look inside themselves to find elements to diff --git a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart index e55fc2cfda..c1f6c9a151 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -3110,10 +3110,7 @@ void _testRoute() { semantics().semanticsEnabled = false; }); - test('scopesRoute alone sets the SemanticRoute role with no label', () { - final List warnings = []; - printWarning = warnings.add; - + test('scopesRoute alone sets the SemanticRoute role and "dialog" ARIA role with no label', () { semantics() ..debugOverrideTimestampFunction(() => _testTime) ..semanticsEnabled = true; @@ -3127,7 +3124,7 @@ void _testRoute() { tester.apply(); expectSemanticsTree(owner(), ''' - + '''); expect(