fix: prevent Rokt layout views from collapsing to zero height - #368
Conversation
Replace flex sizing with cross-axis stretching so SDK-provided heights remain effective inside auto-height column containers. Add iOS and Android style coverage and configure Jest to compile TSX for the regression test. #agentic
PR SummaryLow Risk Overview On iOS and Android, Jest is configured to compile TSX for tests ( Reviewed by Cursor Bugbot for commit 4bf24bb. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR updates the RoktLayoutView platform components to avoid a React Native flexbox interaction where flex: 1 can collapse a view to zero height inside auto-height column parents, ensuring the native-measured height remains effective.
Changes:
- Replaced
flex: 1withalignSelf: 'stretch'in iOS and AndroidRoktLayoutViewstyles to preserve measured height while keeping full-width layout. - Added a cross-platform Jest regression test to assert measured height application, width stretching, and absence of flex properties.
- Updated Jest configuration so TSX/JSX can be compiled for tests (without relying on Metro).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| js/rokt/rokt-layout-view.ios.tsx | Removes flex: 1 and uses alignSelf: 'stretch' to prevent height collapse on iOS. |
| js/rokt/rokt-layout-view.android.tsx | Mirrors the same style fix on Android for consistent layout behavior. |
| js/tests/rokt-layout-view-style.test.tsx | Adds regression coverage for height + width behavior and guards against reintroducing flex sizing. |
| jest.config.js | Adds TSX transform configuration needed for the new Jest regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nickolas-dimitrakas
left a comment
There was a problem hiding this comment.
LGTM, just apply the suggested change from CoPilot
Background
RoktLayoutViewapplies the height reported by the native Rokt SDK, but its existingflex: 1style introduces a zero flex basis that takes precedence over that height inside auto-height column containers. This can collapse a successfully selected placement to zero height.This ports the fix from ROKT/rokt-sdk-react-native#290.
What Has Changed
flex: 1withalignSelf: 'stretch'on the iOS and Android layout views.Screenshots/Video
No visual media was captured. The regression is covered by the new cross-platform layout-style tests and the before/after reproduction details in the upstream PR.
Checklist