Repository navigation
feat(banner)!: take text as message, make hidden content inert - #5056
Conversation
MikitasK
left a comment
There was a problem hiding this comment.
looks pretty solid 👍
just a few points to address before merge:
cc2bc30 to
5181930
Compare
|
Review by Claude WebA banner without actions loses its bottom spacing and the icon moves to the vertical center. Steps: render What happens: the text sits 8px above the bottom edge (it was 16px on the base branch), so the top spacing (24px) and the bottom spacing no longer match. The icon is centered on the text block instead of aligned with the first lines. What should happen: the same spacing and icon position as before, since the PR description does not list this as a change. Base branch: This PR: (via Claude, verify if it makes sense) AndroidThe same spacing and icon change for a banner without actions. Steps: the same as on web. What happens: the last line of text is 8px from the bottom edge, and the icon is centered on the text. What should happen: 16px bottom spacing, as on the base branch. (via Claude, verify if it makes sense) |
satya164
left a comment
There was a problem hiding this comment.
Review by Claude
extractText(line 38) still readschild.props.childrenthroughReact.Children.toArray, and the open thread on it waits for a decision. The project rule is to avoid the Children API and element inspection, so the extraction should go. On Android and web the live region can render{children}itself instead of a string, so it announces whatever the children render, including<Message />. iOS needs a string forannounceForAccessibilityWithOptions, so take it from an explicit prop there, such as themessageAccessibilityLabelproposed in the thread.- The branch conflicts with
maininBanner.tsx, the example, the tests and the snapshot.mainalready moved the example banner below the app bar (#5061), so the rebase should drop theonLayoutpadding and the absolute position from the example. (via Claude, verify if it makes sense)
|
One thing to settle while Banner is reworked: the message is still wrapped in Either Banner supports non-text children (render elements outside the Text), or we document that children are text only. #4179 tried the first on 5.x but broke Text and fragment children. Whichever way 6.0 goes, 5.x will follow. |
d347dc3 to
4c8a76f
Compare
|
@Doberjohn re the <Banner visible message="Payment failed." actions={actions} />
<Banner visible message="Confirm your email" content={<TextInput />} />
cost: breaking, but mechanical, and old usage becomes a type error. rich inline text in the message goes (bold, links), fallback if you don't want to break it in 6.0: keep text children, add which one? i'll do it in this PR. also: does #5016 land before this one? both touch the Banner animation. |
@lukemorawski thanks for the proposal. Let's go with the first option, message: string plus a content slot, as #5072 did for Dialog. |
- `message: string` replaces `children`, so the announcement reads the
prop and no longer walks the children. `content` renders below the
message, outside its Text and outside the live region.
- The live region is a View with `accessibilityLiveRegion`, so Android
announces it. Its Text is added only while there is an announcement.
- Action buttons are keyed by index again, so a label change keeps the
button and its focus. Labels are used only by the focus rescue, which
now also follows an action whose button changed.
- The example gets a banner with a TextInput in `content`.
- The migration guide says what tests can query instead of
`getByRole('alert')`.
BREAKING CHANGE: Banner takes its text as the `message` prop instead of children, and anything else as `content`.
A busy JS thread can take the next show before the report of a hide that already finished on the UI thread. The report then unmounted the content of the visible banner, leaving an empty spacer, and called onHideAnimationFinished after the banner was back. Reports for a state the banner has left are now dropped, for show and hide.
The children walk is gone with the message prop, and the other points were fixed earlier in this PR.
The previous fix only checked the current visible prop. After a hide, a show and a hide, a late report from the first hide still passed: it unmounted the content before the second hide ended and called onHideAnimationFinished twice. Each visible change now gets a number, and a report only counts for the change that started it.
React 19 callback refs can return a cleanup, and Reanimated's animated components run it. mergeRefs dropped it, so a touchableRef passed to a banner action was called with null on detach instead of running its cleanup. mergeRefs now returns a cleanup that runs each ref's own and clears the others.
There was a problem hiding this comment.
🟡 Changes recommended
The banner can clip content when long actions exceed its constrained width, and removing a focused action on web can leave focus lost without falling back to the message.
2 open issues
2 resolved since last review
Review effort: Balanced
On web, the focus rescue can pick a disabled action, or one without a handler, and the browser won't focus either. Focus stayed on the body and the tracker on an action that never had it, so a later change to that action pulled focus back into the banner. The rescue now checks where focus landed and otherwise focuses the message.
The inline layout follows the window width, so a narrow banner in a wide window still put its actions beside the message. The actions row doesn't shrink, so two long labels left the message a few pixels wide. The message now keeps at least half the row, and actions that don't fit beside it wrap onto a line of their own, at its end.
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because hidden banner content can retain or acquire native focus, hidden Android actions remain keyboard-activatable, and web action changes can drop focus.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
|
/review |
Apex Sentinel · ✅ Approve · review of
|
| 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.





Motivation
A hidden
Bannerstayed reachable, its live region was silent on Android and iOS, and aTextInputin it lost focus on each keystroke on iOS.message, the rest incontent.status, oralertwithurgent.Breaking: see the migration guide.
Related issue
Fixes #5055, fixes #4178, part of #4990
Screenshots / Videos
Test plan
Banner example, screen reader on: