From 51d1ded4c8f6c658718536d0f39c04e3d1f3a882 Mon Sep 17 00:00:00 2001 From: vasavk Date: Fri, 5 Apr 2024 21:08:52 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-7135 story: updated variable name for error boolean --- .../DropdownSelect/DropdownSelect.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/VDS/Components/DropdownSelect/DropdownSelect.swift b/VDS/Components/DropdownSelect/DropdownSelect.swift index e9b29a76..76518c93 100644 --- a/VDS/Components/DropdownSelect/DropdownSelect.swift +++ b/VDS/Components/DropdownSelect/DropdownSelect.swift @@ -75,14 +75,11 @@ open class DropdownSelect: Control { /// A callback when the selected option changes. Passes parameters (option). open var onDropdownItemSelect: ((DropdownOptionModel) -> Void)? - - /// Boolean value that determines if component should show the error state/error message. Functon receives the 'event' object on input change. - open var showError: Bool = false { didSet { setNeedsUpdate() }} - + open override var state: UIControl.State { get { var state = super.state - if showError { + if error { state.insert(.error) } return state @@ -209,8 +206,7 @@ open class DropdownSelect: Control { /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { - super.setup() - + super.setup() isAccessibilityElement = true accessibilityLabel = "Dropdown Select" @@ -271,7 +267,7 @@ open class DropdownSelect: Control { container.backgroundColor = backgroundColorConfiguration.getColor(self) container.layer.borderWidth = VDSFormControls.widthBorder container.layer.cornerRadius = VDSFormControls.borderradius - container.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : (showError ? errorBorderColorConfiguration.getColor(self).cgColor : containerBorderColorConfiguration.getColor(self).cgColor) + container.layer.borderColor = readOnly ? readOnlyBorderColorConfiguration.getColor(self).cgColor : (error ? errorBorderColorConfiguration.getColor(self).cgColor : containerBorderColorConfiguration.getColor(self).cgColor) dropdownField.isUserInteractionEnabled = readOnly ? false : true stackView.backgroundColor = transparentBackground ? .clear : surface.color @@ -289,7 +285,7 @@ open class DropdownSelect: Control { /// Used to update any Accessibility properties. open override func updateAccessibility() { super.updateAccessibility() - if showError { + if error { setAccessibilityLabel(for: [eyebrowLabel, selectedOptionLabel, errorLabel, helperLabel]) } else { setAccessibilityLabel(for: [eyebrowLabel, selectedOptionLabel, helperLabel]) @@ -378,7 +374,7 @@ open class DropdownSelect: Control { } open func updateErrorLabel() { - if showError, let errorText { + if error, let errorText { errorLabel.text = errorText errorLabel.surface = surface errorLabel.isEnabled = isEnabled