fix: don't expose handler-less TouchableRipple as a disabled control - #5071
Open
lukemorawski wants to merge 1 commit into
Open
fix: don't expose handler-less TouchableRipple as a disabled control#5071lukemorawski wants to merge 1 commit into
lukemorawski wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
TouchableRipplehadconst disabled = disabledProp || !hasPassedTouchHandler, so anything without a press handler got announced as a disabled control. Split into two flags:Non-controls now render a plain
Animated.Viewinstead of aPressable.Worth knowing why it drops the
Pressableinstead of just passing the caller'sdisabledthrough:disabledalso gates touch-responder claiming (Pressability.js:448,onStartShouldSetResponder: () => !disabled). Fixing only the announcement turns claiming on, so handler-less ripples start swallowing taps.TextInputwraps its field and icons in<Pressable onPress={focusInput}>(TextInput.tsx:352), so tapping a decorative icon stopped focusing the field. Tests stayed green through that.Two things kept on purpose, both break stuff if dropped:
accessible={rest.accessible !== false}, or a checkedCheckboxItemwith no handler loses its role and state.focusable={rest.focusable ?? false}, or on web the icon lands in the tab order, since RNW turnsrole="button"into a real<button>.Related issue
Closes #5070
Supersedes #5011, which fixes the same symptom in
Chip.tsxonly by injecting an emptyonPress. That swaps a false "disabled" for a false "enabled" and leaves the other 21 consumers broken.Test plan
Lint, typecheck and tests pass: 55 suites, 742 tests, 169 snapshots.
The suite can't catch this though. It renders an element tree, never a DOM or a native view, and jest never loads
TouchableRipple.tsxat all. So it's checked on device, example app, TextInput screen with "Leading icon" on. Leading magnifier has no handler, trailing clear button does.enabled: false->trueenabled="false"->"true"<button disabled>-> goneWeb also keeps
tabindex="-1"on the decorative icon.Snapshots are noisy but mechanical: 80 elements drop the
Pressablehandlers and the always-undefineda11y scaffolding. Checked every style key/value pair, nothing net-added. Somearia-*show up raw now becauseView.jsdoes that folding at runtime and the jest preset mocksView.Two extras, worth a look
TextInputIconwas faking disabled by nulling its own handler, which only worked because of this bug. Now passesdisabledthrough.IconButton.getIconColorreturned ondisabledbefore readingcustomIconColor, so onceTextInputIconforwardeddisableda disabled field's icon lost its custom and error colour. Reordered so an explicit colour wins, opacity still shows disabled. No snapshot churn, so nothing else passes both, but it is a public component behaviour change and the bit I'd most want checked.