diff --git a/VDS/BaseClasses/Selector/SelectorItemBase.swift b/VDS/BaseClasses/Selector/SelectorItemBase.swift index 555102a2..3a04b86d 100644 --- a/VDS/BaseClasses/Selector/SelectorItemBase.swift +++ b/VDS/BaseClasses/Selector/SelectorItemBase.swift @@ -11,7 +11,7 @@ import Combine import VDSCoreTokens /// Base Class used to build out a SelectorControlable control. -open class SelectorItemBase: Control, Errorable, Changeable, Groupable { +open class SelectorItemBase: Control, Errorable, Changeable, Groupable { //-------------------------------------------------- // MARK: - Initializers @@ -149,8 +149,13 @@ open class SelectorItemBase: Control, Errorable, open var accessibilityLabelText: String { var accessibilityLabels = [String]() - accessibilityLabels.append("\(Selector.self)") + + if isSelected { + accessibilityLabels.append("selected") + } + accessibilityLabels.append("\(Selector.self)") + if let text = labelText, !text.isEmpty { accessibilityLabels.append(text) } @@ -162,7 +167,7 @@ open class SelectorItemBase: Control, Errorable, if !isEnabled { accessibilityLabels.append("dimmed") } - + if let errorText, showError, !errorText.isEmpty { accessibilityLabels.append("error, \(errorText)") } @@ -177,8 +182,14 @@ open class SelectorItemBase: Control, Errorable, open override func initialSetup() { super.initialSetup() onClick = { [weak self] control in - self?.toggle() + guard let self, isEnabled else { return } + toggle() } + + selectorView.accessibilityDefaultAction = { [weak self] in + guard let self, isEnabled else { return } + toggle() + } } /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. @@ -209,7 +220,6 @@ open class SelectorItemBase: Control, Errorable, open override func updateView() { super.updateView() updateLabels() - selectorView.isUserInteractionEnabled = true selectorView.showError = showError selectorView.isSelected = isSelected selectorView.isHighlighted = isHighlighted @@ -251,14 +261,16 @@ open class SelectorItemBase: Control, Errorable, /// Overriden to take the hit if there is an onClickSubscriber and the view is not a UIControl open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + guard isEnabled else { return super.hitTest(point, with: event) } + let labelPoint = convert(point, to: label) let childLabelPoint = convert(point, to: childLabel) - if label.isAction(for: labelPoint) { return label } else if childLabel.isAction(for: childLabelPoint) { return childLabel } else { + guard !UIAccessibility.isVoiceOverRunning else { return nil } return super.hitTest(point, with: event) } }