Repository navigation
fix!: expand interactive targets to the 48dp minimum - #5108
Conversation
ad60f24 to
f7b7f18
Compare
satya164
left a comment
There was a problem hiding this comment.
Copied from my review on #5080. The layout-measurement feedback below has already been addressed in this PR. The remaining inline comments are copied unchanged.
Remove LLM generated comments. Only add comments where the code maybe unclear and it's necessary.
The touchable should not enforce a minimum hitSlop. Adding unnecessary onLayout everywhere has performance overhead. It should only accept hitSlop prop without layout measurement or minimums. The web version only needs to implement hitSlop since React Native Web doesn't support it.
The actual hitSlop should be passed by components where they are needed, e.g. checkbox. It's simpler and doesn't have require layout measurements.
The following original Chip comment is also already addressed here, since the constants now precede the component JSDoc:
These constants are added between the component and its JSDoc, which will break documentation generation for the component.
271d56a to
8910723
Compare
The component doc comment ended up separated from `const Chip =` by the hitSlop helper constants, so the docs generator could no longer find it.
main removed the hardcoded default testIDs from Chip and IconButton (callstack#5088). Guard Chip's close-icon testID the same way its container already is, and pass explicit testID props in the hitSlop/close-icon tests that relied on the old defaults.
c53d39b to
d3671d7
Compare
|
We've decided Checkbox, Switch and RadioButton should just be 48dp instead of getting an invisible tap area. Could you drop the hit-slop from Checkbox and Switch, keeping Checkbox's |
@JKobrynski I pushed a commit to address that:
One thing I'd like to clarify: with the hit-slop gone, |
|
Review by Claude iOS1. Icon Button with corners set through Steps: open Icon Button, go to Custom, press and hold the square "eye" button ( What happens: the press highlight is a 40dp circle inside the square or custom-shaped button. What should happen: the highlight takes the button's visible shape, as it did on main where the container clipped it. (via Claude, verify if it makes sense) 2. Steps: in What happens: the touchable is 20dp wide and pinned to the left edge of the 40dp button, and it stays full height because What should happen: the button content stays centered and the slop matches the rendered size. (via Claude, verify if it makes sense) Web3. Same IconButton shape problem on hover Steps: open Icon Button, go to Custom, hover the square "eye" button. What happens: the hover fill is a circle inside the square button. What should happen: the hover fill matches the button shape. (via Claude, verify if it makes sense) |
There was a problem hiding this comment.
Review by Claude
The PR description no longer matches the code after the last commit. It still describes hit slop on Checkbox, RadioButton and Switch, the RadioButton tokens file, the Switch web target and the Checkbox and RadioButton rows in the test table. Please update it so the squash message is right. (via Claude, verify if it makes sense)
|
Review by Claude Web1. Chip close button focus ring covers the end of the label Steps: open Chip, press Tab until the close button of the "Close button" chip has focus. What happens: the browser draws the focus ring around the whole 34x32 close column. The ring cuts through the last letter of the label and goes past the top, bottom and right edges of the chip. What should happen: the ring stays around the close icon, inside the chip, as on main. (via Claude, verify if it makes sense) 2. Chip close icon touches the label in RTL Steps: turn on RTL in the drawer, open Chip and look at a chip with a close button. What happens: the close icon sits at the left edge of its column, right next to the label, and leaves 16dp of empty space on its right. What should happen: the icon sits 8dp from the edge of the chip, as on main. (via Claude, verify if it makes sense) |
satya164
left a comment
There was a problem hiding this comment.
Review by Claude
See the inline comments. (via Claude, verify if it makes sense)
|
Found potential problems with the pull request:
|
|
Thanks for the review! All 7 points are addressed in the latest commit, along with satya's inline threads. I re-checked the targets on iOS, Android and web. On the Chip model: #5081 is a draft that was waiting for this PR and #5107 (focus indicators), which is why they diverged. I'd keep this PR's 34dp column with vertical slop: it's space the chip already reserves, so the close target never overlaps the label or the chip body. A 24dp area with slop on all sides would overlap the label, and One open point: on Android with a hardware keyboard, focusing the close button shows the default grey highlight over the whole trailing column (on |
|
Thanks for working through the whole review @k0ndee! @xdimota7x has taken #5108 from here with the rebase on
|
|
Thanks for the update!
Currently, the only blocker is the conflict in |
…ng main The merge with main left the hitSlop describe unclosed, so main's describe.each block ended up inside the last hitSlop test and the file no longer parsed.
There was a problem hiding this comment.
went through the seven points of my last review and the open threads against 296ac11, and they're all addressed. The merge with main kept #5104's Checkbox, #5097's Button and #5046's TouchableRipple changes intact, and typecheck, lint, tests and the build pass on the head and on the head merged with current main.
One blocker, the Chip minHeight (inline), and a few smaller fixes inline.
One more on web, outside the diff: BottomNavigation's tabs render TouchableRipple with borderless, and that was the only clip on the label's path. A label wider than its tab (five tabs on a narrow screen) now spills into the neighbouring tabs, where main cuts it at the tab edge. The bar passes no hitSlop, so overflow: 'hidden' on the tab item on web would bring the clip back.
The points in this review are addressed in later commits or no longer apply after the rework; see the latest review.
- Chip: drop the body minHeight so textStyle-sized chips keep their size,
and give the body slop only when the chip has a touch handler.
- IconButton, TextInput.Icon: a forwarded `hitSlop={undefined}` keeps the
48dp default.
- BottomNavigation: clip tab items on web, where `borderless` no longer
clips a label wider than its tab.
- Docs: scope the `borderless` note to web and note that `hitSlop` now
works on web.
|
Thanks for the review @Doberjohn! I pushed 3d08150 to address it:
New tests cover the Chip handler and disabled cases and the forwarded |
Material Web rings the remove button with a circle around the icon. The ring was a rounded rectangle around the whole 34dp close column from callstack#5108, reaching the label. Focus still lands on the column, so its touch target is unchanged; the ring is drawn outward on a 24dp circle (4/3 of the 18dp icon, like Material Web) inside it, through the 'descendant' scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 34dp close column from callstack#5108 sized itself and its Pressable with `height: '100%'`. On Android the column came out taller than the chip, so the vertically centred glyph, and with it the focus ring, sat below the chip. Stretch the column with `top: 0` / `bottom: 0` and the Pressable with `flex: 1` instead, which lays out the same on web and keeps the glyph centred in the chip on Android. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Material Web rings the remove button with a circle around the icon. The ring was a rounded rectangle around the whole 34dp close column from callstack#5108, reaching the label. Focus still lands on the column, so its touch target is unchanged; the ring is drawn outward on a 24dp circle (4/3 of the 18dp icon, like Material Web) inside it, through the 'descendant' scope.
The 34dp close column from callstack#5108 sized itself and its Pressable with `height: '100%'`. On Android the column came out taller than the chip, so the vertically centred glyph, and with it the focus ring, sat below the chip. Stretch the column with `top: 0` / `bottom: 0` and the Pressable with `flex: 1` instead, which lays out the same on web and keeps the glyph centred in the chip on Android.





Motivation
MD3 requires 48dp touch targets without resizing what is drawn. Each interactive component now computes its own
hitSlopwithgetMinInteractiveSizeHitSlop, andTouchableRippleonly applies it. This coversIconButton,TextInput.Icon,Chip(the close button fills its 34dp column, 48dp tall) andSegmentedButtons. On web, where react-native-web droppedhitSlop,TouchableRipplerenders anaria-hiddentarget instead.Checkbox,SwitchandRadioButtonare resized in #5104, #5102 and #5007,Buttonin #5097.Part of #5079.
Test plan
Typecheck, lint and tests pass. Tapped inside and past the slop on iOS 26.5, Android and web: all targets reach 48dp, a caller
hitSlopwins, and disabled components get none.BREAKING CHANGE: On web
borderlessno longer clips children,IconButtonfeedback ignores corner radii instyle, and taps in aChip's close column callonCloseinstead ofonPress.