Repository navigation
Conversation
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on cd9dfe1. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Four things block the merge:
-
Migration guide. As a breaking PR, it needs before and after entries under
### Listindocs/6.x/docs/guides/migration.md:List.Accordion: the title and icon no longer turnprimarywhen expanded, the header issurfaceinstead ofbackground, the chevron rotates instead of switching tochevron-up, and the content animates and stays mounted until the collapse ends.List.ItemandList.Accordion:bodyLargeandbodyMediumtypography instead offontSize16 and 14, MD3 heights (56, 72 and 88dp) and a 16dp trailing inset instead of 24dp.List.Imagewithvariant="video": a new vertical margin.
For the squash I'd use:
BREAKING CHANGE: List.Item and List.Accordion now use the MD3 list sizes, spacing and theme typography, and List.Accordion keeps its colors when expanded and animates its content. -
Selected colors. The spec tokens give
#E8DEF8and#4A4458for the selected state, which aresecondaryContainerandonSecondaryContainer, not the primary pair. Couldtokens.tsuse those? Better settled before 6.0. -
Button role. A pressable
List.Itemhas no role, so screen readers don't announce it as a button. Could you set it before{...rest}, and movearia-selectedthere too? That also fixes the open thread about it being overwritten.focusRing="inward" role={onPress ? 'button' : undefined} aria-selected={selected} {...rest}
The full test suite passes with this, with no snapshot changes.
-
Deprecate
leftandrightonList.Item. On the question from #5143: we'll keep both in 6.x and removeleftandrightin 7.0. Could you mark them@deprecatedin the JSDoc, pointing toleadingandtrailing(no runtime warning), switch the usage examples inListItem.tsxandListSection.tsxto the slots, and add a line to the migration guide?List.Accordionkeepsleftandrightfor now.
| opacity: contentProgress.value, | ||
| })); | ||
|
|
||
| const onContentLayout = (event: LayoutChangeEvent) => { |
There was a problem hiding this comment.
nit: setting state on every layout re-renders the outer accordion on every frame while a nested one animates. Keeping the height in a shared value would avoid that. Untested.
| style, | ||
| styles.video, | ||
| { | ||
| marginVertical: ListTokens.threeLineVerticalPadding - verticalPadding, |
There was a problem hiding this comment.
nit: style comes first here, so callers can't override this margin. Put it last?
There was a problem hiding this comment.
Hiya! I tried this, but it breaks the common left={(props) => <List.Image variant="video" style={props.style} />} pattern. props.style from left has marginLeft: 16, and marginVertical: 0 when the row has no description. With style last, these win over the video margins, so a one-line video row drops from 88 to 80 and thumbnail moves 16dp. I kept the order for now. Lemme know if you see a better way though
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
all four are fixed now. |
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 6e1aa5f. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
| right={(props) => ( | ||
| <Checkbox | ||
| status="checked" | ||
| aria-label="Headline" | ||
| style={props.style} | ||
| /> | ||
| )} |
There was a problem hiding this comment.
If the left and right props are going to be deprecated, please update examples to use the latest API
| const leadingColor = selected | ||
| ? theme.colors[ListTokens.selectedContentColor] | ||
| : theme.colors[ListTokens.leadingIconColor]; | ||
| const trailingColor = selected | ||
| ? theme.colors[ListTokens.selectedContentColor] | ||
| : theme.colors[ListTokens.trailingIconColor]; |
There was a problem hiding this comment.
These four selected ? selectedContentColor : <token> ternaries (also 201-203, 255-257) repeat what getAccordionColors in utils.ts does for List.Accordion. The only difference is the trailing icon token (trailingIconColor vs expandTrailingIconColor). Could we turn getAccordionColors into a shared helper and use it in both List.Item and List.Accordion, so the selected-state rule lives in one place?
export const getListColors = ({ theme, selected }: { theme: InternalTheme; selected?: boolean }) => {
const pick = (role: ColorRole) =>
theme.colors[selected ? ListTokens.selectedContentColor : role];
return {
titleColor: pick(ListTokens.headlineColor),
descriptionColor: pick(ListTokens.supportingTextColor),
leadingIconColor: pick(ListTokens.leadingIconColor),
trailingIconColor: pick(ListTokens.trailingIconColor),
expandIconColor: pick(ListTokens.expandTrailingIconColor),
};
};Nit: the container* styles and the rowContext useMemo are also the same in ListItem and ListAccordion. They could be shared too.
| export const getLeftStyles = (alignToTop: boolean, description: Description) => | ||
| getAccessoryStyles(alignToTop, description); | ||
|
|
||
| if (!description) { | ||
| return { | ||
| ...styles.iconMarginRight, | ||
| ...styles.marginVerticalNone, | ||
| ...stylesV3, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| ...styles.iconMarginRight, | ||
| ...stylesV3, | ||
| }; | ||
| }; | ||
| export const getRightStyles = (alignToTop: boolean, description: Description) => | ||
| getAccessoryStyles(alignToTop, description); |
There was a problem hiding this comment.
getLeftStyles and getRightStyles are now identical wrappers around getAccessoryStyles. They aren't part of the public API, and only ListUtils.test.tsx uses both. Could we export getAccessoryStyles directly and drop the wrappers?
| const backgroundColor = selected | ||
| ? theme.colors[ListTokens.selectedContainerColor] | ||
| : undefined; | ||
| const titleColor = selected | ||
| ? theme.colors[ListTokens.selectedContentColor] | ||
| : theme.colors[ListTokens.headlineColor]; | ||
|
|
There was a problem hiding this comment.
disabled has no visual state. It reaches TouchableRipple through rest, so the row stops responding to presses but looks exactly like an enabled one. The MD3 tokens (md.comp.list.list-item.disabled.*) set the label, supporting text and leading/trailing icons to onSurface at 0.38 opacity. For a selected row, selected.disabled.container is onSurface at 0.38 opacity as well, not secondaryContainer.
I checked it on the iOS simulator with <List.Item disabled /> and <List.Item selected disabled />. Both render like their enabled counterparts. List.Accordion has no disabled prop at all.
Could we add disabled* entries to tokens.ts, the same way Checkbox and Switch do, and apply them here?
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
src/components/List/ListItem.tsx:319 |
🆕 aria-selected is not announced on role="button"; IconButton uses aria-pressed/aria-checked instead |
Not in the reviewers' prompt (4 files)
src/components/__tests__/__snapshots__/ListAccordion.test.tsx.snap: generated or a lockfile, so its lines were left outsrc/components/__tests__/__snapshots__/ListImage.test.tsx.snap: generated or a lockfile, so its lines were left outsrc/components/__tests__/__snapshots__/ListItem.test.tsx.snap: generated or a lockfile, so its lines were left outsrc/components/__tests__/__snapshots__/ListSection.test.tsx.snap: generated or a lockfile, so its lines were left out
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (9029fbcd5df0).
💬 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: 1 new finding on 70280c9. The verdict and the full list are in the summary comment.
| role={onPress ? 'button' : undefined} | ||
| aria-selected={selected} |
There was a problem hiding this comment.
🆕 🟡 Minor · aria-selected is not announced on role="button"; IconButton uses aria-pressed/aria-checked instead
Setting role="button" together with aria-selected on List.Item or List.Accordion is an invalid ARIA combination—on web the browser drops the state and selection is never announced, making the migration guide's claim "Screen readers announce it as selected" false there. IconButton already uses aria-pressed on web and aria-checked on native for this reason; DrawerItem and BottomNavigation pair role="button" with aria-selected too.
Suggested change
Emit aria-pressed on web and aria-checked on native for selected rows (keyed off selected !== undefined), or document why the button role is excluded here. Re-check the migration-guide sentence against the role actually rendered, and update DrawerItem/BottomNavigation together if the rule is applied repo-wide.
Details
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.
Motivation
Takes over #5143. Brings
List.ItemandList.Accordionin line with the MD3 list spec: tokens, spacing and typography, selected state, animated accordion, andleadingandtrailingslots onList.Item.leftandrightonList.Itemare deprecated.Related issue
Closes #4976
Part of #4930
Screenshots / Videos
list-accordion.mp4
Test plan
In the List example: