Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9efc25d

Browse files
authored
[iOS] Fix slider semantics node answer to accessibility activate (#56427)
## Description iOS fix [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427) per instruction from flutter/flutter#157601 (comment) I don't have a physical iOS device to double check, but using the iOS Simulator and accessibility tools, the behavior seems ok. Without this PR, the slider thumb goes to the center when clicking 'Activate', with this PR it does not : https://github.com/user-attachments/assets/697acadd-7fb1-40a5-ba5a-b549cac381a1 ## Related Issue iOS fix for [[A11y] Double Tap brings the Slider thumb to the center of the widget.](flutter/flutter#156427) ## Tests Adds 1 test.
1 parent 877abb9 commit 9efc25d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

shell/platform/darwin/ios/framework/Source/SemanticsObject.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,13 @@ - (BOOL)accessibilityActivate {
692692
return NO;
693693
}
694694
if (!self.node.HasAction(flutter::SemanticsAction::kTap)) {
695+
// Prevent sliders to receive a regular tap which will change the value.
696+
//
697+
// This is needed because it causes slider to select to middle if it
698+
// does not have a semantics tap.
699+
if (self.node.HasFlag(flutter::SemanticsFlags::kIsSlider)) {
700+
return YES;
701+
}
695702
return NO;
696703
}
697704
self.bridge->DispatchSemanticsAction(self.uid, flutter::SemanticsAction::kTap);

shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,4 +1206,18 @@ - (void)testUIFocusItemContainerConformance {
12061206
XCTAssertTrue([itemsInRect containsObject:child1]);
12071207
XCTAssertTrue([itemsInRect containsObject:child2]);
12081208
}
1209+
1210+
- (void)testSliderSemanticsObject {
1211+
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1212+
new flutter::testing::MockAccessibilityBridge());
1213+
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1214+
1215+
flutter::SemanticsNode node;
1216+
node.flags = static_cast<int32_t>(flutter::SemanticsFlags::kIsSlider);
1217+
SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:0];
1218+
[object setSemanticsNode:&node];
1219+
[object accessibilityBridgeDidFinishUpdate];
1220+
XCTAssertEqual([object accessibilityActivate], YES);
1221+
}
1222+
12091223
@end

0 commit comments

Comments
 (0)