diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index 77477576..e79f36f0 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -22,7 +22,7 @@ open class Tilelet: TileContainerBase { public enum Padding: String, DefaultValuing, CaseIterable { case small case large - + public static var defaultValue: Self { .large } public var value: CGFloat { @@ -63,7 +63,7 @@ open class Tilelet: TileContainerBase { public required init?(coder: NSCoder) { super.init(coder: coder) } - + //-------------------------------------------------- // MARK: - Enums //-------------------------------------------------- @@ -207,7 +207,7 @@ open class Tilelet: TileContainerBase { open var directionalIcon = Icon().with { $0.name = .rightArrow } - + private var _textWidth: TextWidth? /// If provided, width of Button components will be rendered based on this value. If omitted, default button widths are rendered. @@ -270,7 +270,7 @@ open class Tilelet: TileContainerBase { _descriptiveIconModel = nil setNeedsUpdate() } - } + } //-------------------------------------------------- // MARK: - Constraints @@ -288,7 +288,7 @@ open class Tilelet: TileContainerBase { internal var titleLockupEyebrowLabelHeightGreaterThanConstraint: NSLayoutConstraint? internal var titleLockupTitleLabelHeightGreaterThanConstraint: NSLayoutConstraint? internal var titleLockupSubTitleLabelHeightGreaterThanConstraint: NSLayoutConstraint? - + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- @@ -299,9 +299,6 @@ open class Tilelet: TileContainerBase { color = .black addContentView(stackView) - accessibilityTraits = .link - accessibilityElements = [badge, titleLockup, descriptiveIcon, directionalIcon] - //badge badgeContainerView.addSubview(badge) badge @@ -322,7 +319,7 @@ open class Tilelet: TileContainerBase { titleLockupBottomGreaterThanConstraint = titleLockupContainerView.bottomAnchor.constraint(greaterThanOrEqualTo: titleLockup.bottomAnchor) titleLockupTopGreaterThanConstraint = titleLockup.topAnchor.constraint(greaterThanOrEqualTo: titleLockupContainerView.topAnchor) titleLockupCenterYConstraint = titleLockup.centerYAnchor.constraint(equalTo: titleLockupContainerView.centerYAnchor) - + iconContainerView.addSubview(descriptiveIcon) iconContainerView.addSubview(directionalIcon) @@ -351,12 +348,12 @@ open class Tilelet: TileContainerBase { badge.label.setContentCompressionResistancePriority(UILayoutPriority(labelPriority-1), for: .vertical) titleLockup.subTitleLabel.setContentCompressionResistancePriority(UILayoutPriority(labelPriority-2), for: .vertical) titleLockup.eyebrowLabel.setContentCompressionResistancePriority(UILayoutPriority(labelPriority-3), for: .vertical) - + titleLockup.titleLabel.setContentHuggingPriority(UILayoutPriority(labelPriority), for: .vertical) badge.label.setContentHuggingPriority(UILayoutPriority(labelPriority-1), for: .vertical) titleLockup.subTitleLabel.setContentHuggingPriority(UILayoutPriority(labelPriority-2), for: .vertical) titleLockup.eyebrowLabel.setContentHuggingPriority(UILayoutPriority(labelPriority-3), for: .vertical) - + /** Added these constraints for: At fixed width & height if all the labels(Badge, Eyebrow, Title, Subtitle) are having more number of lines then we should display atleast one line of content per label instead of pushing labels out of bounds. @@ -412,7 +409,21 @@ open class Tilelet: TileContainerBase { /// Used to update any Accessibility properties. open override func updateAccessibility() { super.updateAccessibility() - + var elements = [Any]() + if badgeModel != nil { + elements.append(badge) + } + if titleModel != nil || subTitleModel != nil || eyebrowModel != nil { + elements.append(titleLockup) + } + if descriptiveIconModel != nil { + elements.append(descriptiveIcon) + } + if directionalIconModel != nil { + elements.append(directionalIcon) + } + accessibilityElements = elements.count > 0 ? elements : nil + setAccessibilityLabel(for: [badge.label, titleLockup.eyebrowLabel, titleLockup.titleLabel, titleLockup.subTitleLabel]) } diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index a8fab6fa..c0c3b0b5 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -272,7 +272,21 @@ open class TitleLockup: View { titleLabel.textColorConfiguration = textColorPrimaryConfiguration - accessibilityElements = [eyebrowLabel, titleLabel, subTitleLabel] + } + + open override func updateAccessibility() { + super.updateAccessibility() + var elements = [Any]() + if eyebrowModel != nil { + elements.append(eyebrowLabel) + } + if titleModel != nil { + elements.append(titleLabel) + } + if subTitleModel != nil { + elements.append(subTitleLabel) + } + accessibilityElements = elements.count > 0 ? elements : nil } /// Resets to default settings.