diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm index 2fe38516f4..8212c2fd01 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm @@ -692,6 +692,13 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) { return NO; } if (!self.node.HasAction(flutter::SemanticsAction::kTap)) { + // Prevent sliders to receive a regular tap which will change the value. + // + // This is needed because it causes slider to select to middle if it + // does not have a semantics tap. + if (self.node.HasFlag(flutter::SemanticsFlags::kIsSlider)) { + return YES; + } return NO; } self.bridge->DispatchSemanticsAction(self.uid, flutter::SemanticsAction::kTap); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index d0fcaeab2b..ff514b6730 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -1206,4 +1206,18 @@ const float kFloatCompareEpsilon = 0.001; XCTAssertTrue([itemsInRect containsObject:child1]); XCTAssertTrue([itemsInRect containsObject:child2]); } + +- (void)testSliderSemanticsObject { + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); + + flutter::SemanticsNode node; + node.flags = static_cast(flutter::SemanticsFlags::kIsSlider); + SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; + [object setSemanticsNode:&node]; + [object accessibilityBridgeDidFinishUpdate]; + XCTAssertEqual([object accessibilityActivate], YES); +} + @end