Hi, I am looking for help with the following question.
I have a card element on the screen and currently I have the following behaviour.
When the VoiceOver is enabled, the user can switch between elements inside the card and hear their accessibility label. But also the user is able to double tap on any of the elements and navigate to the detailed page.
I want to disable the ability to perform an action when double tapping on elements but keep reading accessibility labels.
I tried to override action for elements and make it empty.
public struct AccessibilityActionDisable: ViewModifier {
public func body(content: Content) -> some View {
content
.accessibilityAction { }
}
}
This does its job and disables the action when you double tap on the element.
Text("24 miles away")
.modifier(AccessibilityActionDisable())
But there is one side effect.
It adds .isButton trait to the element even if it is not a button.
And it is not possible to remove this trait, but I really need to.
So, is it possible to disable the accessibilityAction in some way without this side effect ?