Skip to content

fix: prevent Rokt layout views from collapsing to zero height - #368

Merged
thomson-t merged 1 commit into
mainfrom
fix/rokt-layout-view-zero-height
Jul 29, 2026
Merged

fix: prevent Rokt layout views from collapsing to zero height#368
thomson-t merged 1 commit into
mainfrom
fix/rokt-layout-view-zero-height

Conversation

@thomson-t

@thomson-t thomson-t commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Background

RoktLayoutView applies the height reported by the native Rokt SDK, but its existing flex: 1 style 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

  • Replaced flex: 1 with alignSelf: 'stretch' on the iOS and Android layout views.
  • Preserved full-width rendering while allowing the measured native height to determine the main-axis size.
  • Added comments explaining why flex sizing must not be reintroduced.
  • Added cross-platform regression tests covering measured height, width stretching, and the absence of conflicting flex properties.
  • Configured Jest to compile TSX components for the regression test.

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

  • Self-review completed
  • Tests added or updated
  • Tested locally

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
Copilot AI review requested due to automatic review settings July 29, 2026 15:00
@thomson-t
thomson-t requested a review from a team as a code owner July 29, 2026 15:00
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized layout-style change on Rokt wrapper components with regression tests; no auth, data, or API surface changes.

Overview
Fixes Rokt placements that could render at 0 height inside auto-height column parents even when the native SDK reported a measured height.

On iOS and Android, RoktLayoutView no longer uses flex: 1 on the widget style (which implied a zero flex basis and could win over height on the main axis). It now uses alignSelf: 'stretch' so width still fills the container while the SDK-driven height controls vertical size. Inline comments document why flex: 1 must not return.

Jest is configured to compile TSX for tests (jsx: 'react' under ts-jest). New cross-platform tests assert measured height is applied, flex-related properties are absent, and alignSelf: 'stretch' is set.

Reviewed by Cursor Bugbot for commit 4bf24bb. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: 1 with alignSelf: 'stretch' in iOS and Android RoktLayoutView styles 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.

Comment thread js/__tests__/rokt-layout-view-style.test.tsx

@nickolas-dimitrakas nickolas-dimitrakas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just apply the suggested change from CoPilot

@thomson-t
thomson-t merged commit e149bba into main Jul 29, 2026
12 checks passed
@thomson-t
thomson-t deleted the fix/rokt-layout-view-zero-height branch July 29, 2026 17:42
@rokt-releases rokt-releases Bot mentioned this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants