From b77c7c79e48cfff637156801775c027443980eca Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 2 Jun 2020 15:24:11 -0400 Subject: [PATCH] changes for accessibility --- ...tLeftVariableCheckboxAllTextAndLinks.swift | 13 ++++++++++-- .../ListLeftVariableIconAllTextLinks.swift | 18 +++++++++++++---- ...ftVariableIconWithRightCaretBodyText.swift | 1 + ...tVariableNumberedListAllTextAndLinks.swift | 20 +++++++++++++------ ...ftVariableRadioButtonAllTextAndLinks.swift | 2 +- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index e5da20c5..2edb4b9a 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -102,7 +102,7 @@ import Foundation let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 - isAccessibilityElement = true//!linkShowing + isAccessibilityElement = !linkShowing checkbox.isAccessibilityElement = linkShowing eyebrowHeadlineBodyLink.link.isAccessibilityElement = linkShowing @@ -118,11 +118,20 @@ import Foundation elements.append(checkbox) } - if eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 { + if linkShowing { elements.append(eyebrowHeadlineBodyLink.link) } accessibilityElements = elements } } + + override open func accessibilityActivate() -> Bool { + + if isAccessibilityElement { + return checkbox.accessibilityActivate() + } + + return false + } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconAllTextLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconAllTextLinks.swift index c5ec5d63..1f8a6a43 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconAllTextLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconAllTextLinks.swift @@ -42,7 +42,6 @@ import Foundation leftImage.imageView.contentMode = .scaleAspectFit addMolecule(stack) stack.restack() - isAccessibilityElement = true updateAccessibilityLabel() } @@ -93,11 +92,22 @@ import Foundation accessibilityLabel = message } else { // Allow only radio button and link to be focused on. - accessibilityLabel = message var elements: [UIView] = [] - if message.count > 0 { - elements.append(self) + if let leftImageLabel = leftImage.accessibilityLabel, !leftImageLabel.isEmpty { + elements.append(leftImage) + } + + if let eyeBrowText = eyebrowHeadlineBodyLink.eyebrow.text, !eyeBrowText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.eyebrow) + } + + if let headlineText = eyebrowHeadlineBodyLink.headline.text, !headlineText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.headline) + } + + if let bodyText = eyebrowHeadlineBodyLink.body.text, !bodyText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.body) } if linkShowing { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift index 8603381e..1f982f4f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableIconWithRightCaretBodyText.swift @@ -45,6 +45,7 @@ import Foundation rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal) rightLabel.numberOfLines = 1 + isAccessibilityElement = true addMolecule(stack) stack.restack() updateAccessibilityLabel() diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift index 3bf3c2c1..93daa015 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableNumberedListAllTextAndLinks.swift @@ -46,7 +46,6 @@ import Foundation leftLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) addMolecule(stack) stack.restack() - isAccessibilityElement = true updateAccessibilityLabel() } @@ -107,13 +106,22 @@ import Foundation // Make whole cell focusable if no link. accessibilityLabel = message } else { - // Allow only radio button and link to be focused on. - accessibilityLabel = message - var elements: [UIView] = [] - if message.count > 0 { - elements.append(self) + if let leftLabelText = leftLabel.text, !leftLabelText.isEmpty { + elements.append(leftLabel) + } + + if let eyeBrowText = eyebrowHeadlineBodyLink.eyebrow.text, !eyeBrowText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.eyebrow) + } + + if let headlineText = eyebrowHeadlineBodyLink.headline.text, !headlineText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.headline) + } + + if let bodyText = eyebrowHeadlineBodyLink.body.text, !bodyText.isEmpty { + elements.append(eyebrowHeadlineBodyLink.body) } if linkShowing { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift index d4e2d382..fc26e38b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAllTextAndLinks.swift @@ -109,7 +109,7 @@ import Foundation var elements: [UIView] = [] - if message.count > 0 { + if !message.isEmpty { elements.append(radioButton) }