fix: embedded view collapsing to zero height in a column container - #290
Conversation
`RoktEmbeddedView` styled its own native view with `flex: 1` alongside the
height it receives from the native SDK:
style={[styles.widget, { height: this.state.height }]}
In Yoga, `flex: 1` expands to `flexGrow: 1, flexShrink: 1, flexBasis: 0%`,
and `flexBasis` takes precedence over `height` on the parent's main axis.
Whenever the view is rendered inside an auto-height column container the base
size therefore resolved to 0, `flexGrow` had no free space to distribute, and
the view stayed 0pt tall. The placement was selected, `PlacementReady` and
`PlacementInteractive` fired and the measured height reached JS, but nothing
was ever visible and no impression or view signal followed.
It only worked when the immediate parent happened not to constrain the main
axis, for example a direct child of a `ScrollView` as used in RoktSampleApp,
which is why it went unnoticed.
Replace `flex: 1` with `alignSelf: "stretch"` on both platforms. That still
gives the widget the full available width, but leaves the main axis alone so
the measured `height` applies.
Co-Authored-By: Claude <noreply@anthropic.com>
🛣️ ROKT Data Platform Paved Roads Scan Complete✅ No paved-road issues detected Scanned files against 2 rules. · Reviewed commit: 📜 Scan history (1 scan)
ℹ️ About ROKT Data Platform Paved Roads AgentThis scan was performed by the ROKT Data Platform Paved Roads Agent, an automated paved-road standards review tool for pull requests. See the User Guide for details on severity levels, feedback reactions, and scan configuration. Reply |
🔒 Security Scan Complete✅ No security issues detected Scanned files against 75 rules. · Reviewed commit: 📜 Scan history (1 scan)
ℹ️ About PR Security AgentThis scan was performed by PR Security Agent, an automated security review tool for pull requests. See the User Guide for details on severity levels, feedback reactions, and scan configuration. Reply |
Background
RoktEmbeddedViewstyles its own native view withflex: 1alongside the height it receives from the native SDK:In Yoga,
flex: 1expands toflexGrow: 1, flexShrink: 1, flexBasis: 0%, andflexBasistakes precedence overheighton the parent's main axis. Whenever the view is rendered inside an auto-height column container, the base size resolves to0,flexGrowhas no free space to distribute, and the view stays 0pt tall.The result is a silent failure that looks like a selection or targeting problem: the placement is selected,
PlacementReadyandPlacementInteractivefire, the native SDK reports the measured height to JS, and nothing is ever visible — so no impression or view signal follows.This is easy to miss because it depends entirely on the immediate parent. It works when the parent does not constrain the main axis, for example as a direct child of a
ScrollViewas inRoktSampleApp, which is the arrangement used in our sample app and docs. Wrapping the component in a plain<View>— a very common integration pattern — is enough to trigger it.What Has Changed
flex: 1withalignSelf: "stretch"instyles.widgetin bothrokt-embedded-view.ios.tsxandrokt-embedded-view.android.tsx.alignSelf: "stretch"still gives the widget the full available width in a column layout, but leaves the main axis untouched so the measuredheightapplies.flex: 1must not be reintroduced.Screenshots/Video
Reproduced with a minimal app that renders
<RoktEmbeddedView>inside<View style={{ marginBottom: 24 }}>(an auto-height column parent), on iOS 26.4 simulator, React Native 0.81.5, New Architecture enabled.Before — placement selected and height reported, container never grows:
After — same app, same parent, no consumer-side change: the layout renders at its
reported height.
Checklist
Additional Notes
Rokt.Widget/package.json→"test": "echo \"Error: no test specified\""), so there is nowhere to land a unit test for this. A layout regression test needs a renderer assertion on the resolved height, which would mean introducingjest+react-test-rendererto the package. Happy to do that as a follow-up if we want it.flex: 1fails and the patched style renders, on both4.11.2and4.12.2, inline and inside aModal. Behaviour as a directScrollViewchild is unchanged.5.0.1never deliver the height to JS at all (fixed in fix(android): render embedded placements on New Architecture via EventDispatcher #272). This change is necessary but not sufficient on those older versions.flex: 1pattern exists inmParticle/react-native-mparticle(js/rokt/rokt-layout-view.{ios,android}.tsx), which ports this component asRoktLayoutView. Worth porting this fix there too.Reference Issue (For employees only. Ignore if you are an outside contributor)