From 4e398e696ef811b97144630e41f692ede1a264f0 Mon Sep 17 00:00:00 2001 From: Alex Odawa Date: Tue, 19 Mar 2024 17:21:42 +0100 Subject: [PATCH] moving item accessibility label to the label rather than the value --- BlueprintUILists/Sources/ListReorderGesture.swift | 10 +++++++--- ListableUI/Sources/ListableLocalizedStrings.swift | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/BlueprintUILists/Sources/ListReorderGesture.swift b/BlueprintUILists/Sources/ListReorderGesture.swift index 667bc79a3..a81f59eef 100644 --- a/BlueprintUILists/Sources/ListReorderGesture.swift +++ b/BlueprintUILists/Sources/ListReorderGesture.swift @@ -56,7 +56,7 @@ public struct ListReorderGesture : Element let actions : ReorderingActions /// The acccessibility Label of the item that will be reordered. - /// This will be set as the gesture's accessibilityValue to provide a richer VoiceOver utterance. + /// This will be used to provide a richer VoiceOver utterance useful for disambiguation as to which element will br reordered., public var reorderItemAccessibilityLabel : String? = nil /// Creates a new re-order gesture which wraps the provided element. @@ -171,8 +171,12 @@ fileprivate extension ListReorderGesture func apply(_ model: ListReorderGesture) { blueprintView.element = model.element - proxyElement.accessibilityLabel = ListableLocalizedStrings.ReorderGesture.accessibilityLabel - proxyElement.accessibilityValue = model.reorderItemAccessibilityLabel + if let itemName = model.reorderItemAccessibilityLabel { + proxyElement.accessibilityLabel = String(format: ListableLocalizedStrings.ReorderGesture.accessibilityLabelFormat, itemName) + } else { + proxyElement.accessibilityLabel = ListableLocalizedStrings.ReorderGesture.accessibilityLabel + } + proxyElement.accessibilityHint = ListableLocalizedStrings.ReorderGesture.accessibilityHint proxyElement.accessibilityTraits.formUnion(.button) proxyElement.accessibilityCustomActions = model.accessibilityActions() diff --git a/ListableUI/Sources/ListableLocalizedStrings.swift b/ListableUI/Sources/ListableLocalizedStrings.swift index dc1e67f19..a264ff76a 100644 --- a/ListableUI/Sources/ListableLocalizedStrings.swift +++ b/ListableUI/Sources/ListableLocalizedStrings.swift @@ -19,6 +19,12 @@ public struct ListableLocalizedStrings { value: "Reorder", comment: "Accessibility label for the reorder control on an item") + public static let accessibilityLabelFormat = NSLocalizedString("reorder.AccessibilityLabelFormat", + tableName: nil, + bundle: .listableUIResources, + value: "Reorder %@", + comment: "Accessibility label for a reorder control with a provided name" ) + public static let accessibilityHint = NSLocalizedString("reorder.AccessibilityHint", tableName: nil, bundle: .listableUIResources,