ensure all classes accessibility works the same

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-05-24 10:44:16 -05:00
parent 8cc87fd471
commit 2163abe91a
4 changed files with 44 additions and 20 deletions

View File

@ -145,6 +145,18 @@ open class DatePicker: EntryFieldBase, DatePickerViewControllerDelegate, UIPopov
calendarIcon.color = iconColorConfiguration.getColor(self) calendarIcon.color = iconColorConfiguration.getColor(self)
} }
open override func updateAccessibility() {
super.updateAccessibility()
let label = "Date Picker, \(isReadOnly ? ", read only" : "")"
if let errorText, showError {
fieldStackView.accessibilityLabel = "\(label) ,error, \(errorText)"
} else {
fieldStackView.accessibilityLabel = label
}
fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
fieldStackView.accessibilityValue = value
}
/// Resets to default settings. /// Resets to default settings.
open override func reset() { open override func reset() {
super.reset() super.reset()

View File

@ -132,7 +132,6 @@ open class DropdownSelect: EntryFieldBase {
super.setup() super.setup()
fieldStackView.isAccessibilityElement = true fieldStackView.isAccessibilityElement = true
fieldStackView.accessibilityLabel = "Dropdown Select"
inlineDisplayLabel.isAccessibilityElement = true inlineDisplayLabel.isAccessibilityElement = true
dropdownField.width(0) dropdownField.width(0)
@ -278,9 +277,14 @@ open class DropdownSelect: EntryFieldBase {
open override func updateAccessibility() { open override func updateAccessibility() {
super.updateAccessibility() super.updateAccessibility()
let selectedOption = selectedOptionLabel.text ?? "" let label = "Dropdown Select, \(isReadOnly ? ", read only" : "")"
fieldStackView.accessibilityLabel = "Dropdown Select, \(selectedOption) \(isReadOnly ? ", read only" : "")" if let errorText, showError {
fieldStackView.accessibilityLabel = "\(label) ,error, \(errorText)"
} else {
fieldStackView.accessibilityLabel = label
}
fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open." fieldStackView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
fieldStackView.accessibilityValue = value
} }
open override var accessibilityElements: [Any]? { open override var accessibilityElements: [Any]? {

View File

@ -90,7 +90,6 @@ open class InputField: EntryFieldBase {
open var textField = TextField().with { open var textField = TextField().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
$0.font = TextStyle.bodyLarge.font $0.font = TextStyle.bodyLarge.font
$0.isAccessibilityElement = true
} }
/// Color configuration for the textField. /// Color configuration for the textField.
@ -211,9 +210,21 @@ open class InputField: EntryFieldBase {
super.updateView() super.updateView()
textField.isEnabled = isEnabled textField.isEnabled = isEnabled
textField.isUserInteractionEnabled = isEnabled && !isReadOnly
textField.textColor = textFieldTextColorConfiguration.getColor(self) textField.textColor = textFieldTextColorConfiguration.getColor(self)
} }
open override func updateAccessibility() {
super.updateAccessibility()
let label = "\(isReadOnly ? "read only" : "")"
if let errorText, showError {
textField.accessibilityLabel = "\(label) ,error, \(errorText)"
} else {
textField.accessibilityLabel = label
}
textField.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
}
open override func updateErrorLabel() { open override func updateErrorLabel() {
super.updateErrorLabel() super.updateErrorLabel()
@ -234,7 +245,6 @@ open class InputField: EntryFieldBase {
} else { } else {
successLabel.isHidden = true successLabel.isHidden = true
} }
} }
override func updateRules() { override func updateRules() {
@ -242,12 +252,6 @@ open class InputField: EntryFieldBase {
fieldType.handler().appendRules(self) fieldType.handler().appendRules(self)
} }
/// Used to update any Accessibility properties.
open override func updateAccessibility() {
super.updateAccessibility()
textField.accessibilityLabel = showError ? "error" : nil
}
open override var accessibilityElements: [Any]? { open override var accessibilityElements: [Any]? {
get { get {
var elements = [Any]() var elements = [Any]()

View File

@ -109,7 +109,6 @@ open class TextArea: EntryFieldBase {
$0.isScrollEnabled = false $0.isScrollEnabled = false
$0.textContainerInset = .zero $0.textContainerInset = .zero
$0.textContainer.lineFragmentPadding = 0 $0.textContainer.lineFragmentPadding = 0
$0.isAccessibilityElement = true
} }
open var maxLength: Int? { open var maxLength: Int? {
@ -194,13 +193,24 @@ open class TextArea: EntryFieldBase {
statusIcon.color = iconColorConfiguration.getColor(self) statusIcon.color = iconColorConfiguration.getColor(self)
containerView.layer.borderColor = isReadOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor containerView.layer.borderColor = isReadOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : borderColorConfiguration.getColor(self).cgColor
textView.isEditable = isReadOnly ? false : true textView.isEditable = !isEnabled || isReadOnly ? false : true
textView.backgroundColor = backgroundColorConfiguration.getColor(self) textView.backgroundColor = backgroundColorConfiguration.getColor(self)
textView.tintColor = iconColorConfiguration.getColor(self) textView.tintColor = iconColorConfiguration.getColor(self)
characterCounterLabel.surface = surface characterCounterLabel.surface = surface
highlightCharacterOverflow() highlightCharacterOverflow()
} }
open override func updateAccessibility() {
super.updateAccessibility()
let label = "\(isReadOnly ? "read only" : "")"
if let errorText, showError {
textView.accessibilityLabel = "\(label) ,error, \(errorText)"
} else {
textView.accessibilityLabel = label
}
textView.accessibilityHint = isReadOnly || !isEnabled ? "" : "Double tap to open."
}
override func updateRules() { override func updateRules() {
super.updateRules() super.updateRules()
@ -225,12 +235,6 @@ open class TextArea: EntryFieldBase {
return stackView return stackView
} }
/// Used to update any Accessibility properties.
open override func updateAccessibility() {
super.updateAccessibility()
textView.accessibilityLabel = showError ? "error" : nil
}
open override var accessibilityElements: [Any]? { open override var accessibilityElements: [Any]? {
get { get {
var elements = [Any]() var elements = [Any]()