fix: MessageView rendering on sizes smaller than screen size - #287
Closed
mrzzy wants to merge 1 commit into
Closed
Conversation
by reading view size from onGeometryChange
f3dm76
reviewed
Jul 27, 2026
| maxWidth: UIScreen.main.bounds.width, | ||
| alignment: message.user.isCurrentUser ? .trailing : .leading | ||
| ) | ||
| .onGeometryChange(for: CGFloat.self) { proxy in |
Collaborator
There was a problem hiding this comment.
GeometryChange on every cell is a big overhead, let's replace this with only calculating the width once. cells all have the same width - chatView's width. it can be calculated once on the very top of hierarchy and passed wherever it's needed
f3dm76
requested changes
Jul 27, 2026
Collaborator
|
Hey @mrzzy, please check out version 3.2.9, should be fixed there, have a great day! |
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.
Fix
MessageViewrendering in containers narrower than the screenMotivation
MessageViewcurrently usesUIScreen.main.bounds.widthto determine the available width for laying out message content and choosing the time view arrangement (hstack,overlay, orvstack).This works when the chat occupies the full screen, but breaks when
MessageViewis embedded in a container that is narrower than the device screen (for example, side panels, sheets, split views, or custom layouts).Because the layout logic overestimates the available width, it may incorrectly choose the horizontal (
hstack) layout, resulting in truncated or clipped message content.Changes
UIScreen.main.bounds.widthin the layout calculation with the actual rendered width ofMessageView.@Stateproperty to track the current view width.onGeometryChangeandGeometryReaderso layout decisions are based on the real available space instead of the device screen width.This preserves the existing behavior for full-screen chats while allowing
MessageViewto render correctly when hosted inside narrower containers.