You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In short - the has-valid-accessibility-descriptors's rule's error message is static text that doesn't take into account the config's settings on whether accessibilityHint is actually required with accessibilityLabel.
We have eslint-plugin-react-native-a11y set up with has-accessibility-hint rule disabled on a library of components intended to be shared between web and native projects, because accessibilityHint isn't supported in React Native Web, so mandating its use risks misleading devs into thinking an element has full contextual info when actually the hint part is unavailable on Web. Instead, we advise devs to use complete labels that contain full contextual info across platforms.
We recently updated to 3.x and were surprised to see an error seemingly complaining about missing hints with labels:
Missing a11y props. Expected one of: accessibilityRole OR BOTH accessibilityLabel + accessibilityHint OR BOTH accessibilityActions + onAccessibilityAction
...however, it turns out that the rule was correctly following our settings: if the element in question was given an accessibilityLabel without an accessibilityHint, there was no error as per our disabling of the accessibilityHint rule, but if the accessibilityLabel prop was removed, then the error misleadingly implied an accessibilityHint was also needed.
So the behaviour is fine, but the error message didn't reflect the behaviour of the rule.
Proposed fix
Replace the BOTH accessibilityLabel + accessibilityHint part of the error message here
'Missing a11y props. Expected one of: accessibilityRole OR BOTH accessibilityLabel + accessibilityHint OR BOTH accessibilityActions + onAccessibilityAction';
with just accessibilityLabel if the appropriate accessiblityHint rule is not active.
The text was updated successfully, but these errors were encountered:
AlanSl
changed the title
Error for -descriptors rule is out of sync with accessibility-hint rule setting
Error message for -descriptors rule is out of sync with accessibility-hint rule setting
Apr 22, 2022
In short - the
has-valid-accessibility-descriptors
's rule's error message is static text that doesn't take into account the config's settings on whetheraccessibilityHint
is actually required withaccessibilityLabel
.We have eslint-plugin-react-native-a11y set up with
has-accessibility-hint
rule disabled on a library of components intended to be shared between web and native projects, becauseaccessibilityHint
isn't supported in React Native Web, so mandating its use risks misleading devs into thinking an element has full contextual info when actually the hint part is unavailable on Web. Instead, we advise devs to use complete labels that contain full contextual info across platforms.We recently updated to
3.x
and were surprised to see an error seemingly complaining about missing hints with labels:...however, it turns out that the rule was correctly following our settings: if the element in question was given an
accessibilityLabel
without anaccessibilityHint
, there was no error as per our disabling of the accessibilityHint rule, but if theaccessibilityLabel
prop was removed, then the error misleadingly implied anaccessibilityHint
was also needed.So the behaviour is fine, but the error message didn't reflect the behaviour of the rule.
Proposed fix
Replace the
BOTH accessibilityLabel + accessibilityHint
part of the error message hereeslint-plugin-react-native-a11y/src/rules/has-valid-accessibility-descriptors.js
Line 18 in e5b0f97
accessibilityLabel
if the appropriate accessiblityHint rule is not active.The text was updated successfully, but these errors were encountered: