Skip to content

Commit

Permalink
Fix UpdateSemantics for UIStepper and UIPagerControl (#11937) (#12217)
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBaseOfT.Tests.cs
  • Loading branch information
PureWeen authored Dec 19, 2022
1 parent 34e160c commit 87f1bea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Core/src/Platform/iOS/SemanticExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ public static void UpdateSemantics(this UIView platformView, IView view)
platformView.AccessibilityLabel = semantics.Description;
platformView.AccessibilityHint = semantics.Hint;

// UIControl elements automatically have IsAccessibilityElement set to true
if (platformView is not UIControl && (!string.IsNullOrWhiteSpace(semantics.Hint) || !string.IsNullOrWhiteSpace(semantics.Description)))
platformView.IsAccessibilityElement = true;
if ((!string.IsNullOrWhiteSpace(semantics.Hint) || !string.IsNullOrWhiteSpace(semantics.Description)))
{
// Most UIControl elements automatically have IsAccessibilityElement set to true
if (platformView is not UIControl)
platformView.IsAccessibilityElement = true;
// UIStepper and UIPageControl inherit from UIControl but iOS marks `IsAccessibilityElement` to false
// because they are composite controls.
else if (platformView is UIStepper || platformView is UIPageControl)
platformView.IsAccessibilityElement = true;
}

if (semantics.IsHeading)
{
Expand Down

0 comments on commit 87f1bea

Please sign in to comment.