From 99978ead114ed07189e06a1d9e945ea8335010e9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 2 May 2024 11:49:24 -0500 Subject: [PATCH] CXTDT-552842 - Accessibility - Breadcrumbs - The breadcrumb links are not properly placed within a breadcrumbs region. Signed-off-by: Matt Bruce --- .../Breadcrumbs/BreadcrumbItem.swift | 2 +- VDS/Components/Breadcrumbs/Breadcrumbs.swift | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Breadcrumbs/BreadcrumbItem.swift b/VDS/Components/Breadcrumbs/BreadcrumbItem.swift index a7b9bef4..f12d9646 100644 --- a/VDS/Components/Breadcrumbs/BreadcrumbItem.swift +++ b/VDS/Components/Breadcrumbs/BreadcrumbItem.swift @@ -96,7 +96,7 @@ open class BreadcrumbItem: ButtonBase { /// Used to update any Accessibility properties. open override func updateAccessibility() { super.updateAccessibility() - accessibilityLabel = "Breadcrumb \(text ?? "")" + accessibilityLabel = text } } diff --git a/VDS/Components/Breadcrumbs/Breadcrumbs.swift b/VDS/Components/Breadcrumbs/Breadcrumbs.swift index 63084192..7c88e18a 100644 --- a/VDS/Components/Breadcrumbs/Breadcrumbs.swift +++ b/VDS/Components/Breadcrumbs/Breadcrumbs.swift @@ -39,6 +39,13 @@ open class Breadcrumbs: View { } } + open override var accessibilityElements: [Any]? { + get { + return [containerView, breadcrumbs] + } + set {} + } + /// A callback when the selected item changes. Passes parameters (crumb). open var onBreadcrumbDidSelect: ((BreadcrumbItem) -> Void)? @@ -73,6 +80,11 @@ open class Breadcrumbs: View { return collectionView }() + private let containerView = View().with { + $0.isAccessibilityElement = true + $0.accessibilityLabel = "Breadcrumbs" + } + //-------------------------------------------------- // MARK: - Private Methods //-------------------------------------------------- @@ -106,8 +118,10 @@ open class Breadcrumbs: View { /// Executed on initialization for this View. open override func initialSetup() { super.initialSetup() - addSubview(collectionView) + containerView.addSubview(collectionView) collectionView.pinToSuperView() + addSubview(containerView) + containerView.pinToSuperView() } /// Resets to default settings. @@ -124,7 +138,7 @@ open class Breadcrumbs: View { super.updateView() collectionView.reloadData() } - + open override func layoutSubviews() { //Turn off the ability to execute updateView() in the super //since we don't want an infinite loop @@ -139,6 +153,7 @@ open class Breadcrumbs: View { } } private var separatorWidth = Label().with { $0.text = "/"; $0.sizeToFit() }.intrinsicContentSize.width + } extension Breadcrumbs: UICollectionViewDelegate, UICollectionViewDataSource, ButtongGroupPositionLayoutDelegate {