diff --git a/CHANGELOG.md b/CHANGELOG.md index 15646204ffb..7b7d77c3038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Swift package `SwiftLintPlugins` from v0.60.0 to v0.60.1 - Update various GitHub Actions workflows dependencies - Tuning of themes (like rounded corners) (Orange-OpenSource/ouds-ios#951) + ### Fixed +- Filter chip component should not have a button trait (Orange-OpenSource#956) - Badge component does not have bigger sizes if text sizes is increased (Orange-OpenSource#844) ## [0.18.0](https://github.com/Orange-OpenSource/ouds-ios/compare/0.17.0...0.18.0) - 2025-09-05 diff --git a/OUDS/Core/Components/Sources/Controls/Chip/OUDSFilterChip.swift b/OUDS/Core/Components/Sources/Controls/Chip/OUDSFilterChip.swift index 69c14ebf8f6..198316fafa9 100644 --- a/OUDS/Core/Components/Sources/Controls/Chip/OUDSFilterChip.swift +++ b/OUDS/Core/Components/Sources/Controls/Chip/OUDSFilterChip.swift @@ -124,13 +124,20 @@ public struct OUDSFilterChip: View { // TODO: #407 - Add documentation hyperlink Chip(layout: layout, selected: selected, interactionState: ChipInteractionState(with: $0)) } .accessibilityAddTraits(selected ? [.isSelected] : []) - .accessibilityAddTraits(.isButton) + .accessibilityRemoveTraits([.isButton]) .accessibilityHint(accessibilityHint) .accessibilityLabel(accessibilityLabel) + .modifier(IsToggleModifier()) } + /// If the device OS is > iOS 17, the toggle trait is added thanks to `IsToggleModifier`. + /// Thus an hint is automatically added and a custom hint is not needed anymore/ private var accessibilityHint: String { - (selected ? "core_filterchip_hint_selected_a11y" : "core_filterchip_hint_unselected_a11y").localized() + if #available(iOS 17.0, *) { + "" + } else { + (selected ? "core_filterchip_hint_selected_a11y" : "core_filterchip_hint_unselected_a11y").localized() + } } private var accessibilityLabel: String { diff --git a/OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/AccessibleModifiers.swift b/OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/Navigation and focus View Modfiers.swift similarity index 100% rename from OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/AccessibleModifiers.swift rename to OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/Navigation and focus View Modfiers.swift diff --git a/OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/Traits Modifiers.swift b/OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/Traits Modifiers.swift new file mode 100644 index 00000000000..1eb17174928 --- /dev/null +++ b/OUDS/Core/Components/Sources/_/ViewModifiers/AccessibleModifiers/Traits Modifiers.swift @@ -0,0 +1,31 @@ +// +// Software Name: OUDS iOS +// SPDX-FileCopyrightText: Copyright (c) Orange SA +// SPDX-License-Identifier: MIT +// +// This software is distributed under the MIT license, +// the text of which is available at https://opensource.org/license/MIT/ +// or see the "LICENSE" file for more details. +// +// Authors: See CONTRIBUTORS.txt +// Software description: A SwiftUI components library with code examples for Orange Unified Design System +// + +import SwiftUI + +/// A `ViewModifier` adding the `isToggle` trait to the target view +/// if and only if the operating system is at least**iOS 17.0**. +struct IsToggleModifier: ViewModifier { + + func body(content: Content) -> some View { + #if canImport(UIKit) // Remember: doc is generated with non-iOS aware tool... + if #available(iOS 17.0, *) { + content.accessibilityAddTraits(.isToggle) + } else { + content + } + #else + content + #endif + } +}