From 0ec165701bb776add76d89d873f4d6f1b86eec5e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Jun 2024 13:39:18 -0500 Subject: [PATCH] CXTDT-577463 - InputField - Accessible Elements for actionLink/credit Card image, status image - fixed issue with success text Signed-off-by: Matt Bruce --- .../TextFields/InputField/InputField.swift | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index 2ca4c207..575e843f 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -196,6 +196,33 @@ open class InputField: EntryFieldBase { borderColorConfiguration.setSurfaceColors(VDSColor.feedbackSuccessOnlight, VDSColor.feedbackSuccessOndark, forState: .success) textField.textColorConfiguration = textFieldTextColorConfiguration + + containerView.bridge_accessibilityLabelBlock = { [weak self] in + guard let self else { return "" } + var accessibilityLabels = [String]() + + if let text = titleLabel.text?.trimmingCharacters(in: .whitespaces) { + accessibilityLabels.append(text) + } + if isReadOnly { + accessibilityLabels.append("read only") + } + if !isEnabled { + accessibilityLabels.append("dimmed") + } + if let errorText, showError { + accessibilityLabels.append("error, \(errorText)") + } + + if let successText, showSuccess { + accessibilityLabels.append("success, \(successText)") + } + + accessibilityLabels.append("\(Self.self)") + + return accessibilityLabels.joined(separator: ", ") + } + } open override func getFieldContainer() -> UIView { @@ -260,11 +287,20 @@ open class InputField: EntryFieldBase { get { var elements = [Any]() elements.append(contentsOf: [titleLabel, containerView]) - if showError { + if let leftView = textField.leftView { + elements.append(leftView) + } + + if !statusIcon.isHidden{ elements.append(statusIcon) - if let errorText, !errorText.isEmpty { - elements.append(errorLabel) - } + } + + if !actionTextLink.isHidden { + elements.append(actionTextLink) + } + + if let errorText, !errorText.isEmpty, showError || hasInternalError { + elements.append(errorLabel) } else if showSuccess, let successText, !successText.isEmpty { elements.append(successLabel) }