Repository navigation
Conversation
|
Found potential problems with the pull request:
|
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on 58d3075. The verdict and the full list are in the summary comment.
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings and 1 moved to a new line on 25e3177. The verdict and the full list are in the summary comment.
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 finding moved to a new line on 69a6fe0. The verdict and the full list are in the summary comment.
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
src/components/TouchableRipple/utils.ts:79 |
Hover layer replaces a backgroundImage the consumer set through style |
Not in the reviewers' prompt (1 file)
src/components/__tests__/__snapshots__/TouchableRippleWeb.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 (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: 1 finding moved to a new line on 69a6fe0. The verdict and the full list are in the summary comment.
| export const getHoverStyle = (hoverColor: ColorValue): ViewStyle | undefined => | ||
| typeof hoverColor === 'string' | ||
| ? { backgroundImage: `linear-gradient(${hoverColor}, ${hoverColor})` } | ||
| : undefined; |
There was a problem hiding this comment.
🟡 Minor · Hover layer replaces a backgroundImage the consumer set through style
A consumer that sets backgroundImage in style (gradient, texture) loses it for the whole hover: getHoverStyle spreads a backgroundImage after style, so react-native-web's flattened style takes the hover gradient. The previous hover used backgroundColor, which left a consumer backgroundImage untouched; on web there is now no way to keep both.
Suggested change
Note the hover layer in the TouchableRipple section of docs/6.x/docs/guides/migration.md: while hovered it occupies backgroundImage, so a gradient or image set on the touchable through style is hidden for the duration of the hover.
Details
persona: senior-developer, 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.
There was a problem hiding this comment.
@apex-sentinel-staging note Known tradeoff, it's documented on getHoverStyle. Composing needs the resolved backgroundImage from style, and this repo bans StyleSheet.flatten in src because animated styles can't be flattened. backgroundImage on a touchable is rare, so I kept the replace. Lemme know what you think
There was a problem hiding this comment.
Updated suggestion
Your reasoning checks out: eslint.config.mjs does error on StyleSheet.flatten, so composing the consumer's gradient from inside getHoverStyle isn't available, and the docblock on getHoverStyle now spells the replace out for maintainers. My ask was never to change the replace, though — it was the migration note: the docblock is a source comment, so a web user with a gradient set through style only finds out by bisecting, and the TouchableRipple section of migration.md currently mentions the borderless, hitSlop and focusRing changes but not this one. Downgrading to a nit for that one documentation line; the behavior itself I'd merge as is.
🔵 Nit · Note in migration.md that the web hover layer replaces a backgroundImage set through style
On web, a touchable whose style sets backgroundImage (a gradient or texture) loses that background for the whole hover, because TouchableRipple.tsx appends getHoverStyle(hoverColor) after style and react-native-web's flattened style takes the hover gradient. The replace is a deliberate tradeoff and is documented in the getHoverStyle docblock, which is fine; what a consumer will not see is that source comment. The TouchableRipple section of docs/6.x/docs/guides/migration.md covers borderless, hitSlop and focusRing but not this, so it is worth one sentence saying the hover layer occupies backgroundImage while hovered.
Suggested change
Add a sentence to the ### TouchableRipple section of docs/6.x/docs/guides/migration.md: on web the hover layer is a CSS background image, so while the touchable is hovered it replaces a backgroundImage (gradient or image) set on it through style; a backgroundColor set that way is unaffected, since the hover layer paints on top of it. No change to getHoverStyle or to the style ordering in TouchableRipple.tsx — the repo bans StyleSheet.flatten in src, so composing the two gradients from inside the helper isn't an option.
Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.
Motivation
This is a followup to: #5224 (comment)
On web,
TouchableRipplepaints hover as its ownbackgroundColor, and abackgroundColorinstyleovverides it. So a selectedDrawer.Itemor a selectedList.Itemfrom #5224, shows no hover effect.Hover is now a
linear-gradientbackground image afterstyle. It paints on top of the background color and keeps the border radius. Hover no longer fades in as it cannot animate background image.Related issue
Follow-up to #5224 (comment)
Screenshots / Videos
Test plan
In the web example:
Drawer.Item. The hover layer shows on top of the selected color, with rounded corners.Button. They look as before.