fix: avoid disabled accessibility state for active chips#5011
Conversation
matkoson
left a comment
There was a problem hiding this comment.
src/components/Chip/Chip.tsx:217 @vivekjm wouldn't this make non-interactive chips ripple when pressed?
generated by an automated pr-review pipe, not written by a human. reply and tag the repo owner if it got something wrong.
|
Thanks for checking this. The intent is not to make non-interactive chips behave as actionable controls, only to prevent them from being exposed as disabled to accessibility APIs when the Chip itself is not disabled.\n\nThe fallback no-op handler is only used when the chip is not disabled and no touch handler was passed. It avoids TouchableRipple deriving a disabled accessibility state from the missing handler; explicitly disabled chips still pass through as disabled, and chips with real handlers still use their provided onPress/onPressIn/onPressOut behavior.\n\nIf you prefer avoiding a no-op onPress entirely, I can rework this to keep the accessibility state independent from TouchableRipple's disabled inference instead. |
Motivation
Fixes an accessibility regression where Chips without an explicit disabled prop can still be exposed as disabled/dimmed to screen readers.
TouchableRipplemarks itself disabled when no touch handler is present, so informational or selected Chips could inherit a disabled accessibility state even though the Chip itself is not disabled.This keeps explicitly disabled Chips disabled, while allowing non-disabled Chips to remain active from an accessibility perspective.
Related issue
Fixes #4844
Test plan
yarn test src/components/__tests__/Chip.test.tsx --runInBand -uyarn eslint src/components/Chip/Chip.tsx src/components/__tests__/Chip.test.tsxyarn typescriptAlso attempted the default pre-commit hook, which runs full lint/types/tests. Lint and most tests ran, but the full Jest run failed in
src/babel/__tests__/index.jsbecause this checkout does not havelib/mappings.jsongenerated.