Skip to content

Commit 68877f8

Browse files
committed
Add accessibility labels and hints to order list views
Introduces accessibility labels and hints for the search button and order rows in POSOrderListView to improve screen reader support. Ghost order rows are now hidden from accessibility. Localization keys for these labels and hints have been added.
1 parent 4d4e2cd commit 68877f8

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

WooCommerce/Classes/POS/Presentation/Orders/POSOrderListView.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct POSOrderListView: View {
4444
analytics.track(event: WooAnalyticsEvent.PointOfSale.ordersListSearchButtonTapped())
4545
setSearch(true)
4646
}
47+
.accessibilityLabel(Localization.searchButtonAccessibilityLabel)
4748
.matchedGeometryEffect(id: Constants.searchControlID, in: searchTransition)
4849
.transition(.opacity.combined(with: .scale))
4950
}
@@ -218,6 +219,19 @@ private struct POSOrderRowView: View {
218219
.stroke(Color.posOnSurface, lineWidth: 2)
219220
}
220221
}
222+
.accessibilityElement(children: .combine)
223+
.accessibilityLabel(accessibilityLabel)
224+
.accessibilityHint(POSOrderListView.Localization.orderRowAccessibilityHint)
225+
}
226+
227+
private var accessibilityLabel: String {
228+
POSOrderListView.Localization.orderRowAccessibilityLabel(
229+
orderNumber: order.number,
230+
total: order.formattedTotal,
231+
date: DateFormatter.dateAndTimeFormatter.string(from: order.dateCreated),
232+
email: order.customerEmail,
233+
status: order.status.localizedName
234+
)
221235
}
222236

223237
@ViewBuilder
@@ -281,6 +295,7 @@ private struct POSGhostOrderRowView: View {
281295
.background(Color.posSurfaceContainerLowest)
282296
.posItemCardBorderStyles()
283297
.geometryGroup()
298+
.accessibilityHidden(true)
284299
}
285300

286301
@ViewBuilder
@@ -387,6 +402,39 @@ extension POSOrderListView {
387402
)
388403
return String(format: format, orderNumber)
389404
}
405+
406+
static func orderRowAccessibilityLabel(orderNumber: String, total: String, date: String, email: String?, status: String) -> String {
407+
let baseFormat = NSLocalizedString(
408+
"pos.orderListView.orderRow.accessibilityLabel",
409+
value: "Order #%1$@, Total %2$@, %3$@, Status: %4$@",
410+
comment: "Accessibility label for order row. %1$@ is order number, %2$@ is total amount, %3$@ is date and time, "
411+
+ "%4$@ is order status."
412+
)
413+
var label = String(format: baseFormat, orderNumber, total, date, status)
414+
415+
if let email = email, email.isNotEmpty {
416+
let emailFormat = NSLocalizedString(
417+
"pos.orderListView.orderRow.accessibilityLabel.email",
418+
value: "Email: %1$@",
419+
comment: "Email portion of order row accessibility label. %1$@ is customer email address."
420+
)
421+
label += ", " + String(format: emailFormat, email)
422+
}
423+
424+
return label
425+
}
426+
427+
static let orderRowAccessibilityHint = NSLocalizedString(
428+
"pos.orderListView.orderRow.accessibilityHint",
429+
value: "Tap to view order details",
430+
comment: "Accessibility hint for order row indicating the action when tapped."
431+
)
432+
433+
static let searchButtonAccessibilityLabel = NSLocalizedString(
434+
"pos.orderListView.searchButton.accessibilityLabel",
435+
value: "Search orders",
436+
comment: "Accessibility label for the search button in orders list."
437+
)
390438
}
391439
}
392440

0 commit comments

Comments
 (0)