Repository navigation
Conversation
|
can you rebase the PR against main? |
There was a problem hiding this comment.
Pull request overview
This PR modernizes RadioButton for Material Design 3 by replacing the prior platform-specific implementations with a single unified component, introducing MD3 token-based sizing/color resolution, and aligning behavior (animation, error/disabled states, a11y, and group performance) with the library’s other MD3 selection controls.
Changes:
- Unifies
RadioButtoninto a single MD3 implementation (removingRadioButton.Android,RadioButton.IOS, and theRadioButton.Itemmodeprop) and migrates selection animation toreact-native-reanimated. - Adds MD3 radio tokens +
errorsupport, applies disabled opacity consistently, and updates selection-control color resolution to use tokenized theme roles. - Improves
RadioButton.Groupcontext stability and updates tests/examples/docs accordingly (including removing platform-specific docs pages).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.tsx | Removes exported platform-specific RadioButton prop types. |
| src/components/RadioButton/utils.ts | Updates selection-control color resolution to use RadioButton tokens and removes iOS-specific helper. |
| src/components/RadioButton/tokens.ts | Introduces MD3 radio sizing + color-role tokens. |
| src/components/RadioButton/RadioButtonItem.tsx | Removes mode, adds error, switches to useContext, and adjusts a11y/testID behavior. |
| src/components/RadioButton/RadioButtonGroup.tsx | Memoizes context value and stabilizes onValueChange with use-latest-callback. |
| src/components/RadioButton/RadioButtonAndroid.tsx | Deletes old Android-specific implementation. |
| src/components/RadioButton/RadioButtonIOS.tsx | Deletes old iOS-specific implementation. |
| src/components/RadioButton/RadioButton.tsx | Implements unified MD3 RadioButton with Reanimated dot-scale animation, tokenized sizes/colors, and updated a11y behavior. |
| src/components/RadioButton/index.ts | Removes .Android/.IOS static exports from RadioButton. |
| src/components/tests/RadioButton/utils.test.tsx | Updates tests to cover getSelectionControlColor including error/checked/unchecked cases. |
| src/components/tests/RadioButton/RadioButtonItem.test.tsx | Removes platform-mode tests and adds a11y single-node assertion. |
| src/components/tests/RadioButton/RadioButtonGroup.test.tsx | Adds test asserting stable context object across unrelated parent rerenders. |
| src/components/tests/RadioButton/RadioButton.test.tsx | Simplifies snapshots to single unified RadioButton implementation. |
| src/components/tests/RadioButton/snapshots/RadioButtonItem.test.tsx.snap | Updates snapshots for new unified control + a11y changes. |
| src/components/tests/RadioButton/snapshots/RadioButtonGroup.test.tsx.snap | Updates snapshots for new unified control rendering. |
| src/components/tests/RadioButton/snapshots/RadioButton.test.tsx.snap | Updates snapshots for unified control rendering. |
| example/src/Examples/RadioButtonItemExample.tsx | Updates example to remove mode variants and demonstrate error/disabled states. |
| example/src/Examples/RadioButtonGroupExample.tsx | Updates example usage to RadioButton (no platform statics). |
| example/src/Examples/RadioButtonExample.tsx | Updates example states, adds error demos, and adjusts disabled label styling. |
| docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonItem.mdx | Removes documentation for the deleted mode prop. |
| docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonIOS.mdx | Removes iOS-specific docs page. |
| docs/versioned_docs/version-6.x/components/RadioButton/RadioButtonAndroid.mdx | Removes Android-specific docs page. |
| docs/docusaurus.config.js | Removes nav entries for the deleted platform-specific docs pages. |
cb74fc8 to
c0e1c18
Compare
- Fix accessibilityLabel variable reference (ariaLabel, not accessibilityLabel) - Make sync render() calls async in RadioButton and RadioButtonItem tests - Await rerender() in RadioButtonGroup stability test - Use screen.queryAllByRole instead of destructuring from render result - Update snapshots to reflect accessibilityRole instead of role prop
Nested ternary indentation left misaligned after conflict resolution.
RadioButtonAndroid and RadioButtonIOS were removed but the navigation index still referenced them, breaking the docs build.
RadioButtonAndroid and RadioButtonIOS source mappings caused the docs build to fail with ENOENT since the files no longer exist.
- Restore onPress type to (e: GestureResponderEvent) => void to match TouchableRipple - Merge consumer style with container style, handling function-style props - Guard RadioButtonItem label testID to avoid "undefined-text" when testID is not provided
| const sizes = { | ||
| ringSize: 20, | ||
| dotSize: 10, | ||
| outlineWidth: 2, | ||
| } as const; |
There was a problem hiding this comment.
what about adding an explicit state-layer size token & sizing touchable accordingly?
current 20dp ring with 8dp margins produces 36dp state layer, while MD3 defines radio state layer as 40dp.
modernized Checkbox component already uses the same 40dp state-layer token (source)
so could we change it to:
| const sizes = { | |
| ringSize: 20, | |
| dotSize: 10, | |
| outlineWidth: 2, | |
| } as const; | |
| const sizes = { | |
| ringSize: 20, | |
| dotSize: 10, | |
| outlineWidth: 2, | |
| stateLayerSize: 40, | |
| } as const; |
and use like that in RadioButton.tsx:
const {
ringSize,
dotSize,
outlineWidth: OUTLINE_WIDTH,
stateLayerSize,
} = RadioButtonTokens;
const styles = StyleSheet.create({
container: {
width: stateLayerSize,
height: stateLayerSize,
borderRadius: stateLayerSize / 2,
alignItems: 'center',
justifyContent: 'center',
},
radio: {
height: ringSize,
width: ringSize,
borderRadius: ringSize / 2,
borderWidth: OUTLINE_WIDTH,
},
});…into feat/radio-button-md3 # Conflicts: # src/components/RadioButton/RadioButtonAndroid.tsx # src/components/RadioButton/RadioButtonIOS.tsx # src/components/RadioButton/RadioButtonItem.tsx
MikitasK
left a comment
There was a problem hiding this comment.
- updated radio-button state layer to MD3 specified 40dp size while keeping visible ring centered at 20dp
- added reusable
stateLayerSizetoken & removed previous margin-based state-layer sizing - made nested visual control inside
RadioButton.Itemnon-focusable withfocusable={false}andtabIndex={-1}keeping outer item as the only interactive radio - added regression coverage for
40dpstate layer & updated affected accessibility & component snapshots
|
@MikitasK is this ready for another review? |
JKobrynski
left a comment
There was a problem hiding this comment.
Add a ### RadioButton entry to docs/6.x/docs/guides/migration.md. The iOS variant drew a checkmark, so anyone on it gets a visibly different control. #5059 has a ### Checkbox section covering the identical removals that would work as the template, but it skips RadioButton and still lists RadioButton.Android / RadioButton.IOS as live. Worth syncing with @mikolajadamowicz on which PR carries it.
updated |
|
Review by Claude The press and hover state layer covers the whole 48dp touch target. The MD3 radio state layer is 40dp, and the new 40dp iOSSteps: open Radio Button, press and hold the "Error (Checked)" radio. (via Claude, verify if it makes sense) AndroidSteps: open Radio Button, press and hold the "Error (Checked)" radio. (via Claude, verify if it makes sense) WebSteps: open (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)
nice finding 👍 |
|
/review |
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
src/components/RadioButton/RadioButton.tsx:260 |
RadioButton no longer sets aria-live, so selection changes stop being announced |
docs/component-docs.config.ts:8 |
screenshotsV6 deletes the RadioButton.Item screenshot from the v6 docs; its stated 5.x justification doesn't hold |
docs/src/data/screenshots.ts:107 |
v5-only screenshots entries removed from the shared map used by the 5.x doc generator |
Not in the reviewers' prompt (3 files)
src/components/__tests__/RadioButton/__snapshots__/RadioButton.test.tsx.snap: generated or a lockfile, so its lines were left outsrc/components/__tests__/RadioButton/__snapshots__/RadioButtonGroup.test.tsx.snap: generated or a lockfile, so its lines were left outsrc/components/__tests__/RadioButton/__snapshots__/RadioButtonItem.test.tsx.snap: generated or a lockfile, so its lines were left out
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.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on e51f07f. The verdict and the full list are in the summary comment.
|
|
||
| const handlePressOut = React.useCallback( | ||
| (e: GestureResponderEvent) => { | ||
| setPressed(false); | ||
| onPressOut?.(e); | ||
| }, | ||
| [onPressOut] | ||
| ); | ||
|
|
||
| // When `accessible={false}` is passed (typically by `RadioButton.Item`, | ||
| // which owns the a11y tree for the wrapped row), suppress our own role and |
There was a problem hiding this comment.
🟡 Minor · RadioButton no longer sets aria-live, so selection changes stop being announced
A screen reader user toggling a standalone RadioButton via an external control (pointerEvents="none") no longer hears the checked state change because accessibilityProps only emits role, aria-disabled and aria-checked—the aria-live="polite" the platform-specific predecessors set is gone. The v6 migration guide's RadioButton section does not mention this removal.
Suggested change
Restore aria-live="polite" on the standalone control (outside the accessible === false branch), or state in the RadioButton section of docs/6.x/docs/guides/migration.md that per-radio live-region announcements were removed.
Details
Also raised here
Also raised at this location by persona react-native-paper: RadioButton drops the aria-live announcement the platform variants had — RadioButtonAndroid/RadioButtonIOS both set aria-live="polite" on their touchable; the new single implementation's accessibilityProps (RadioButton.tsx 273-280) sets only role, aria-disabled and aria-checked, so a standalone radio that flips state via an external status prop is no longer announced. The modernized Checkbox in this checkout still emits 'aria-live': 'polite' as const for exactly that case (src/components/Checkbox/Checkbox.tsx 232), so add it for parity — or say so in the migration note, which currently doesn't mention the change.
Also raised at this location by persona senior-developer: Standalone RadioButton lost aria-live="polite"; screen readers no longer announce checked changes — A standalone <RadioButton> that a group or parent flips programmatically (e.g. status updated from a network load, or a RadioButton.Group value change) is no longer announced: both removed implementations set aria-live="polite" on their TouchableRipple (RadioButtonAndroid/RadioButtonIOS), and the new accessibilityProps block emits only role/aria-disabled/aria-checked. The component the PR says it mirrors, Checkbox, still ships 'aria-live': 'polite' in the same block (src/components/Checkbox/Checkbox.tsx:227), so this is a divergence from the stated model, not just a removal. The PR description scopes the live-region drop to "Item a11y", where the inner control is accessible={false} anyway, but it silently applies to the standalone radio too, and migration.md's RadioButton section doesn't mention it.
persona: maintainability, react-native-paper, senior-developer, 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.
| // 6.x-only overrides: the v5 iOS radio assets show a control this release | ||
| // removes, but `generate-5x-docs.ts` still renders them from the shared map. | ||
| const screenshotsV6: Record<string, unknown> = { | ||
| ...screenshots, | ||
| 'RadioButton.Group': 'screenshots/radio-button-group-android.gif', | ||
| }; | ||
| delete screenshotsV6['RadioButton.Item']; |
There was a problem hiding this comment.
🟡 Minor · screenshotsV6 deletes the RadioButton.Item screenshot from the v6 docs; its stated 5.x justification doesn't hold
Deleting screenshotsV6['RadioButton.Item'] removes the only entry that render.ts:130 looks up by doc.title, so the v6 RadioButton.Item page now renders no <ScreenshotTabs> at all. The comment's justification—that 5.x iOS radio assets are still rendered from the shared map—is incorrect because generate-5x-docs.ts builds its custom fields from the archived 5.x branch's own docs/docusaurus.config.js and docs/src/data/screenshots.js and never imports component-docs.config.ts. The RadioButton.Group override also replaces Android/iOS tab data with a single string.
| // 6.x-only overrides: the v5 iOS radio assets show a control this release | |
| // removes, but `generate-5x-docs.ts` still renders them from the shared map. | |
| const screenshotsV6: Record<string, unknown> = { | |
| ...screenshots, | |
| 'RadioButton.Group': 'screenshots/radio-button-group-android.gif', | |
| }; | |
| delete screenshotsV6['RadioButton.Item']; | |
| const screenshotsV6: Record<string, unknown> = { | |
| ...screenshots, | |
| 'RadioButton.Group': 'screenshots/radio-button-group-android.gif', | |
| }; |
Details
Also raised here
Also raised at this location by persona react-native-paper: V6 RadioButton.Item doc page loses its screenshot, RadioButton keeps a v5 asset — docs/component-docs.config.ts deletes 'RadioButton.Item' from screenshotsV6, so the generated 6.x RadioButton.Item page renders no screenshot at all even though the component changed its row height (52→64dp) and a11y structure in this PR — the one place a reviewer would see the new row. Meanwhile the RadioButton entry still points at screenshots/radio-enabled.android.png / radio-disabled.android.png, captures of the 36dp control this PR replaced with the 48dp one. Ship refreshed v6 assets (or keep an explicit entry) for both pages instead of dropping one and reusing the other's stale image.
persona: senior-developer, 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.
| Modal: 'screenshots/modal.gif', | ||
| ProgressBar: 'screenshots/progress-bar.png', | ||
| RadioButton: { | ||
| 'Android (enabled)': 'screenshots/radio-enabled.android.png', | ||
| 'Android (disabled)': 'screenshots/radio-disabled.android.png', | ||
| 'iOS (enabled)': 'screenshots/radio-enabled.ios.png', | ||
| 'iOS (disabled)': 'screenshots/radio-disabled.ios.png', | ||
| }, | ||
| 'RadioButton.Android': { | ||
| enabled: 'screenshots/radio-enabled.android.png', | ||
| disabled: 'screenshots/radio-disabled.android.png', | ||
| }, |
There was a problem hiding this comment.
🟡 Minor · v5-only screenshots entries removed from the shared map used by the 5.x doc generator
This PR deletes RadioButton.Android, RadioButton.IOS, RadioButton.Item-iOS, and RadioButton: Android/iOS (enabled|disabled) from docs/src/data/screenshots.ts, which is the shared map consumed by both the 6.x rspress config and the 5.x docs pipeline; the 5.x pages referencing those keys now render with missing images. The new screenshotsV6 + delete screenshotsV6['RadioButton.Item'] approach is exactly what the 6.x-only override exists to avoid — the deletions should be 6.x-only too.
Details
Also raised here
Also raised at this location by persona react-native-paper: Shared screenshot map loses the iOS radio assets the v5 docs still need — The v5 RadioButton documentation loses its iOS screenshots: docs/scripts/generate-5x-docs.ts builds its custom fields from the raw screenshots export (screenshots: screenshotsModule.screenshots, line 161), not from the new screenshotsV6 override, and this diff deleted RadioButton['iOS (enabled)'], RadioButton['iOS (disabled)'], 'RadioButton.Android' and 'RadioButton.IOS' entries from that shared export. The comment above screenshotsV6 in docs/component-docs.config.ts states the intent is the opposite — that generate-5x-docs.ts should keep rendering the v5 iOS assets from the shared map. Keeping the removed keys in src/data/screenshots.ts and deleting them only in screenshotsV6 achieves that; as written the v5 5.x pages that still document RadioButton.IOS render without a screenshot.
persona: javascript, 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.








Motivation
RadioButtonstill shipped as two platform-specific implementations (RadioButtonAndroid,RadioButtonIOS) with the iOS variant rendering a checkmark glyph rather than a Material radio. This is inconsistent with the rest of the v6 MD3 work (Checkbox, Switch, TextInput, FAB) and diverges from the M3 radio button spec.This PR unifies RadioButton into a single MD3 component that mirrors the modernized Checkbox structure (single component,
tokens.ts,errorprop,accessible={false}inner control), without pulling in Checkbox's reanimated/focus-ring machinery (out of scope — radio ships with none today).Related issue
Closes #4938
What changed
RadioButtonAndroid+RadioButtonIOSinto a single MD3RadioButton(Android impl as base). DroppedRadioButton.Android,RadioButton.IOS,RadioButtonIOS, and theRadioButton.Itemmodeprop.RadioButton/tokens.ts(MD3 dims20/10/2+ color roles); colors resolved via tokens inutils.errorprop — added toRadioButtonandRadioButton.Item(ring + dot usetheme.colors.error;disabled/custom colors take precedence).Animated.Values into one shared value and migrated toreact-native-reanimated(matching Checkbox): dot scales in with overshoot on selection, keyed oncheckedso it also animates inside aRadioButton.Group. Usestheme.motionMD3 duration/easing tokens and respects reduce-motion.selectionControlOpacitywas previously computed but never applied).onValueChangewithuse-latest-callback; consumers switched fromContext.ConsumertouseContext.accessible={false}+ containerimportantForAccessibility="no-hide-descendants", so a screen reader sees one radio per row; dropped per-radioaccessibilityLiveRegion;labelMaxFontSizeMultiplier=1.5+${testID}-textfor CheckboxItem parity.RadioButtonAndroid/RadioButtonIOSdoc pages.Breaking changes
RadioButton.Android,RadioButton.IOS,RadioButtonIOS(andRadioButtonAndroidProps/RadioButtonIOSPropsexports).RadioButton.Itemmodeprop.errorprop added (no visual change for existing usage).Test plan
yarn typescript,yarn lint,yarn test(snapshots updated) — green.yarn --cwd docs build— green.Videos
radio_ios.mp4
radio_android.mp4
radio_web.mp4