Skip to content

refactor(chip): MD3 improvements - #5238

Open
kachmashk wants to merge 6 commits into
callstack:mainfrom
kachmashk:refactor/chip-improvements
Open

kachmashk wants to merge 6 commits into
callstack:mainfrom
kachmashk:refactor/chip-improvements

Conversation

@kachmashk

@kachmashk kachmashk commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Breaking API and behavior

  • Changes the default mode from flat to outlined.
  • Removes the compact and showSelectedOverlay props; the selected overlay is now handled automatically for avatars.
  • Reworks selected, outlined, disabled, icon/avatar and close-icon color resolution (getChipColors in utils.ts, renamed from helpers.tsx) to align with MD3 state and color roles, with a dedicated ripple color and avatar selected-overlay color.
  • A focused outlined chip shows the focus outline color instead of selectedColor.
  • Removes the press-time elevation animation in favor of a static elevation derived from the elevated and disabled props.

Accessibility, focus and interaction

  • Replaces the hand-rolled reanimated focus ring with the shared useFocusRing hook, as Button, Card and FAB do.
  • Draws the body ring once, on the Surface, and passes focusRing="none" to both ripples so TouchableRipple no longer adds a second ring.
  • Wraps the trailing/close button in an unclipped view that carries its own ring, so the ripple's circular clipping can't cut it off.
  • Renders a trailing icon without a handler as a decorative view: no button role, label, ripple, hit slop or focus ring.
  • Adds a 48dp minimum touch target via hitSlop, and moves the close icon into TouchableRipple for consistent ripple/state-layer feedback.
  • Removes the trailing icon's left hitSlop so it doesn't overlap the label's touch area.
  • Stops dimming the disabled avatar twice.

More including cleanups, docs, example app and tests.

Motivation

Align the Chip component with Material Design 3 guidelines and specs.

Related issue

refactor(chip): improve selection model and MD3 compliance #4931
feat: implement Chip component #5081

Screenshots / Videos

chips-merged

Test plan

Run the example app (ChipExample) on iOS, Android and web, in light and dark themes, and click through every chip. Then turn on VoiceOver (iOS) or TalkBack (Android) and swipe through them.

  • Looks: outlined by default, flat, elevated, selected (check icon, or check over an avatar) and disabled chips match MD3 in both themes.
  • Press: the body and the close or trailing button each ripple and fire only their own handler, including taps just above, below and right of the trailing button. A trailing icon without a handler does nothing.
  • Keyboard (web, Android): Tab shows exactly one ring per control, on the chip body and separately on the trailing button. Disabled chips and chips with no handler are skipped.
  • Screen reader: the chip is announced as a button with its selected and disabled state, and the close and trailing buttons use their labels. A trailing icon without a handler is not announced as a button.
  • Docs: the migration guide matches this behavior.

@kachmashk kachmashk self-assigned this Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Found potential problems with the pull request:

  • The description is too long. Please keep it under 1000 characters.

@kachmashk
kachmashk marked this pull request as ready for review November 19, 2026 15:00
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 9 new findings on ac535b2. The verdict and the full list are in the summary comment.

Comment thread src/components/Chip/Chip.tsx Resolved
Comment thread src/components/Chip/Chip.tsx Resolved
Comment thread src/components/Chip/Chip.tsx Resolved
Comment thread src/components/Chip/Chip.tsx Resolved
Comment thread src/components/Chip/Chip.tsx Resolved
Comment on lines 365 to 370
<TouchableRipple
borderless
background={background}
style={[{ borderRadius }, styles.touchable, ...bodyFocusTarget.style]}
rippleColor={rippleColor}
style={[styles.touchable, { borderRadius }, ...bodyFocusTarget.style]}
focusRing="none"

@apex-sentinel-staging apex-sentinel-staging Bot Nov 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 520457a, with the code it pointed at unchanged: withdrawn, not fixed.

🟡 Minor · Chip body draws the browser's outline plus Paper's ring on web

Tabbing to a chip on web shows two focus indicators: the Surface's :has() ring from bodyFocusRing and the browser's own outline on the focused Pressable. focusRing="none" on the body ripple only suppresses Paper's ring, and useFocusRing adds webNoOutlineStyle only for scope: 'descendant', not the scope: 'within' the chip body uses.

Suggested change

Confirm on web in the ChipExample that a keyboard-focused chip shows exactly one ring; if the browser outline appears as well, set outline: 'none' on the body ripple's style the way the trailing button's unclipped wrapper does.

Details

persona: react-native-paper

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Comment on lines +375 to +376
onHoverIn={() => setHovered(true)}
onHoverOut={() => setHovered(false)}

@apex-sentinel-staging apex-sentinel-staging Bot Nov 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 520457a.

🟡 Minor · elevated hover elevation unreachable on a chip with no touch handler

An elevated chip with no onPress/onLongPress/onPressIn/onPressOut stays at elevation 1 on hover: setHovered is only wired to TouchableRipple's onHoverIn/onHoverOut, and with no touch handler TouchableRipple renders a plain View (isControl === false) that never fires hover events. The hover state also never clears if the chip is disabled or loses its handler while hovered, since the element that would fire onHoverOut is gone.

Details

persona: senior-developer

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Comment on lines +375 to +376
onHoverIn={() => setHovered(true)}
onHoverOut={() => setHovered(false)}

@apex-sentinel-staging apex-sentinel-staging Bot Nov 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 520457a.

🟡 Minor · hovered state never resets when the pointer leaves without hover-out

An elevated chip stays at elevatedHoverElevation (2) instead of elevatedElevation (1) when the pointer leaves without a hover-out — e.g. the chip scrolls out of the list under the cursor, an overlay/tooltip mounts over it, or the window loses focus. Nothing resets hovered except onHoverOut, which never arrives in those sequences.

Suggested change

Clear hovered when the chip loses focus (and/or disable it while isTouchableDisabled), so a lost hover-out can't leave the chip permanently raised.

Details

persona: javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Comment on lines +377 to +385
onFocus={(e) => {
bodyFocusTarget.onFocus?.(e);
if (e.target !== e.currentTarget || !isKeyboardFocusEvent(e)) return;
setFocused(true);
}}
onBlur={() => {
bodyFocusTarget.onBlur?.();
setFocused(false);
}}

@apex-sentinel-staging apex-sentinel-staging Bot Nov 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 520457a: the code it pointed at changed.

🟡 Minor · focused/hovered state never resets when the chip stops being interactive

Focus a chip, then set disabled while focus is inside: focused stays true, onBlur never fires (the chip is no longer focusable), and getBorderColor returns focusOutlineColor (onSurfaceVariant) instead of the disabled border. hovered persists the same way for an elevated chip disabled mid-hover, currently masked by the disabled ? 0 branch of elevation.

Suggested change

Skip the focused branch when disabled/isTouchableDisabled, or pass focused && !isTouchableDisabled into getChipColors.

Details

persona: senior-developer

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · 🟠 Request changes · review of 520457a

Since the review of ac535b2: 1 new · 0 still open · 9 no longer raised (2 marked fixed)

1 finding(s): 1 major.

Required fixes

  • Chip label lost flexShrink, so long labels are clipped instead of ellipsized

🟠 Major (1)

Where Finding
src/components/Chip/Chip.tsx:535 🆕 Chip label lost flexShrink, so long labels are clipped instead of ellipsized
Not in the reviewers' prompt (5 files)
  • docs/public/gallery/chip-dark.png: no text diff (a binary, empty or mode-only change)
  • docs/public/gallery/chip.png: no text diff (a binary, empty or mode-only change)
  • docs/public/screenshots/chip.png: no text diff (a binary, empty or mode-only change)
  • src/components/__tests__/__snapshots__/Chip.test.tsx.snap: generated or a lockfile, so its lines were left out
  • src/components/__tests__/__snapshots__/ListItem.test.tsx.snap: generated or a lockfile, so its lines were left out

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (c8c3a3945ccb).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 520457a. The verdict and the full list are in the summary comment.

Comment on lines +535 to 538
labelText: {
textAlignVertical: 'center',
includeFontPadding: false,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆕 🟠 Major · Chip label lost flexShrink, so long labels are clipped instead of ellipsized

A Chip whose label is wider than its available space now hard-clips the text with no ellipsis. The labelText style no longer carries flexShrink: 1 (Yoga's default flexShrink is 0), so the Text keeps its measured width while styles.content shrinks and its overflow: 'hidden' cuts the overflow. The ellipsizeMode prop has nothing to act on since numberOfLines={1} only ellipsizes when the text is given a narrower width.

Suggested change
labelText: {
textAlignVertical: 'center',
includeFontPadding: false,
},
labelText: {
textAlignVertical: 'center',
includeFontPadding: false,
flexShrink: 1,
},
Details

persona: senior-developer

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant