diff --git a/engine/src/flutter/shell/platform/common/accessibility_bridge.cc b/engine/src/flutter/shell/platform/common/accessibility_bridge.cc index b491f31480..b0a4757c92 100644 --- a/engine/src/flutter/shell/platform/common/accessibility_bridge.cc +++ b/engine/src/flutter/shell/platform/common/accessibility_bridge.cc @@ -257,6 +257,10 @@ void AccessibilityBridge::SetRoleFromFlutterUpdate(ui::AXNodeData& node_data, node_data.role = ax::mojom::Role::kToggleButton; return; } + if (flags & kFlutterSemanticsFlagIsSlider) { + node_data.role = ax::mojom::Role::kSlider; + return; + } // If the state cannot be derived from the flutter flags, we fallback to group // or static text. if (node.children_in_traversal_order.size() == 0) { diff --git a/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc b/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc index 7a92e5ecbf..38e0382666 100644 --- a/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc +++ b/engine/src/flutter/shell/platform/common/accessibility_bridge_unittests.cc @@ -314,5 +314,28 @@ TEST(AccessibilityBridgeTest, ToggleHasToggleButtonRole) { EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kToggleButton); } +TEST(AccessibilityBridgeTest, SliderHasSliderRole) { + std::shared_ptr bridge = + std::make_shared( + std::make_unique()); + FlutterSemanticsNode root{.id = 0}; + root.flags = static_cast( + FlutterSemanticsFlag::kFlutterSemanticsFlagIsSlider | + FlutterSemanticsFlag::kFlutterSemanticsFlagHasEnabledState | + FlutterSemanticsFlag::kFlutterSemanticsFlagIsEnabled | + FlutterSemanticsFlag::kFlutterSemanticsFlagIsFocusable); + root.actions = static_cast(0); + root.text_selection_base = -1; + root.text_selection_extent = -1; + root.label = "root"; + root.child_count = 0; + root.custom_accessibility_actions_count = 0; + bridge->AddFlutterSemanticsNodeUpdate(&root); + bridge->CommitUpdates(); + + auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock(); + EXPECT_EQ(root_node->GetData().role, ax::mojom::Role::kSlider); +} + } // namespace testing } // namespace flutter