Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questionable Accessibility Advice #5364

Open
chriscm2006 opened this issue Nov 22, 2023 · 2 comments
Open

Questionable Accessibility Advice #5364

chriscm2006 opened this issue Nov 22, 2023 · 2 comments
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.

Comments

@chriscm2006
Copy link

chriscm2006 commented Nov 22, 2023

New Issue Checklist

A fellow friend of mine passionate about iOS Accessibility shared this issue description with me.

https://github.com/realm/SwiftLint/blob/ff1e966e3ae8ef9876ec5e80c060a46b5faae8f4/Source/SwiftLintBuiltInRules/Rules/Lint/AccessibilityTraitForButtonRule.swift

I love the idea of a Linting library for Accessibility. I actually built one attached to LLVM for Deque back like 10 years ago attached to CLANG for Objective C analysis... The logic I found analyzing UIView ASTSs back then applies to Swift the same. This rule needs some help :).

The description for this issues suggests that every tappable iOS Control should be Button or a Link. This shows a misunderstanding of what these traits do and their relationship to the Rotor. Counterexamples to this rule include:

  • Interactive GridView Items - Like the iOS launcher screen.
  • Switches, checkboxes, etc.
  • Interactive selectable ListViewCells

Note: There are more counter examples than examples.

A rule that would more accurately satisfy the documented intent of this rule would be a rule that made sure controls that were attempting to exhibit single tap behavior did so utilizing gestures that Voice Control and Switch Control recognize as having a default action... being clickable.

Or even a rule that recommended removing the Trait of Button or Link from a control with a changing value... "Switch Button" should never happen.

Let's chat! :) https://www.linkedin.com/in/ciaiguy/

@chriscm2006 chriscm2006 changed the title Bad Accessibility Advice Questionable Accessibility Advice Nov 22, 2023
@SimplyDanny
Copy link
Collaborator

@rcole34: You originally contributed the rule. Mentioning you in case you are interested in a chat with @chriscm2006. Unfortunately, I don't have enough experience in this area to judge the apparently conflicting opinions on the rule.

@SimplyDanny SimplyDanny added the discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. label Nov 23, 2023
@rcole34
Copy link
Contributor

rcole34 commented Nov 23, 2023

Hey @chriscm2006 thanks for the feedback! I agree this rule may not be perfect for all scenarios, but I added it to help counteract a common anti-pattern I was seeing in a lot of SwiftUI code where developers would just add a tap gesture to views rather than using a Button to avoid dealing with unwanted ButtonStyle behaviors. This resulted in views that visually looked like buttons, but had no indication with VoiceOver that they were interactive. There are definitely exceptions where it’s ok to not have a button trait, but I still think the consequences of having a view that assistive technologies do not see as interactive are much worse than the consequences of having a trait where it’s not strictly needed.

I do agree though that we could add the isToggle trait to the list of things you could add along with a tap gesture to not have the rule warn about adding a button trait.

At the end of the day, plenty of SwiftLint rules aren’t about the “right” or “wrong” way to do something and are more suggestions for what is someone’s idea of better style. This is an opt-in rule that people can turn on if they choose, and the target audience for this and the accessibility label for image rule that I added is more people who are getting started with accessibility or are trying to have a gentle reminder for their development team to be thinking about accessibility in their process. If you have ideas for a heuristic that could be used to determine when it would be fine to omit the trait then feel free to contribute to the open source project if you have ideas to make it better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.
Projects
None yet
Development

No branches or pull requests

3 participants