Repository navigation
Prevent negative item widths when available space is exhausted - #168
Merged
bryankeller merged 1 commit intoSep 24, 2026
Merged
Conversation
jordanmcadoo
marked this pull request as ready for review
September 24, 2026 17:44
jordanmcadoo
force-pushed
the
jordanm--clamp-item-width
branch
from
September 24, 2026 17:47
ebab4cb to
d4e524d
Compare
bryankeller
approved these changes
Sep 24, 2026
bryankeller
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Agreed that negative sizes should not be possible.
4 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change summary
Clamp calculated item widths to zero when the available space is smaller than the configured insets and inter-item spacing.
Context
Layout can run before a collection view has a usable width, or while its bounds are temporarily smaller than its insets and spacing. The current calculation can produce negative item widths, resulting in invalid cell geometry.
Clamping the result prevents invalid widths while preserving normal layout once sufficient space is available.
Before / after
How was it tested?
xcodebuild test -project MagazineLayout.xcodeproj -scheme MagazineLayout -destination "platform=iOS Simulator,name=iPhone 17,OS=26.5" CODE_SIGNING_ALLOWED=NO— 65 tests passed.