Skip to content

Clamp finite frame max width to parent bounds - #510

Draft
caspersimon wants to merge 2 commits into
skiptools:mainfrom
caspersimon:codex/issue-339-frame-max-clamp
Draft

Clamp finite frame max width to parent bounds#510
caspersimon wants to merge 2 commits into
skiptools:mainfrom
caspersimon:codex/issue-339-frame-max-clamp

Conversation

@caspersimon

Copy link
Copy Markdown

Summary

Fixes Modifier.frame(maxWidth:) on Android so a finite maximum width is clamped by tighter incoming parent constraints, matching SwiftUI behavior.

The max-only branch used Compose requiredWidthIn(max:), which permits the child to measure wider than its parent and then centers the oversized result. This changes only that branch to widthIn(max:). The existing min-only and min-plus-max behavior is unchanged.

Closes #339.

Verification

  • Added an Android matrix to the existing testFrameMaxWidthRespectsParentBounds:
    • parent 400, max 680 → 400
    • parent 680, max 680 → 680
    • parent 800, max 680 → 680
    • parent 400, max infinity → 400
  • Regression commit reproduced the defect on Android: the first case measured 680 instead of 400.
  • With the one-line fix, the same four-case Android test passed (1 test executed).
  • swift test --filter LayoutTests.testFrameMaxWidthRespectsParentBounds passed on the host platform (1 test, 0 failures).

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device
  • REQUIRED: I have checked whether this change requires a corresponding update in the Skip Fuse UI repository. No Fuse update is required; the defect is isolated to SkipUI's Android modifier mapping.
  • OPTIONAL: I have added an example of any UI changes to the Showcase sample app

  • AI was used to generate or assist with generating this PR. AI helped trace the failing modifier branch and draft the regression matrix and PR description. I manually verified the scoped diff, reproduced the regression before applying the fix, reran the identical Android test after the fix, inspected the generated Kotlin, and ran the targeted Swift test.

@cla-bot

cla-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to the Skip community. We require contributors to sign our contributor license agreement (CLA), and we don't seem to have the user(s) @caspersimon on file. In order for us to review and merge your code, for each noted user please add your GitHub username to Skip's .clabot file

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.

.frame(maxWidth:) ignores parent bounds

1 participant