Skip to content

Honor concrete width proposals in UIKit sizeThatFits - #27

Open
felipefdl wants to merge 1 commit into
LiYanan2004:mainfrom
felipefdl:fix/ios-width-proposal
Open

Honor concrete width proposals in UIKit sizeThatFits#27
felipefdl wants to merge 1 commit into
LiYanan2004:mainfrom
felipefdl:fix/ios-width-proposal

Conversation

@felipefdl

Copy link
Copy Markdown

Fixes #26.

On iOS, _TextView_UIKit.sizeThatFits returned uiView.sizeThatFits(...) directly. UITextView.sizeThatFits reports the used (snug) width, so SwiftUI sized the representable to its longest line. Inside flexible containers, short-lined content (ordered lists through MarkdownView's MarkdownText, for example) collapsed into a narrow column: 98 pt in a 390 pt window, with list head indents wrapping item text character by character and copy(_:) truncating at the laid-out region.

This change honors a concrete width proposal and keeps the fitted size only when the proposal has no width, matching how the AppKit path fills its container. Verified on an iOS 26 simulator with the reproduction test from #26: the collapsed case goes from 98 pt to the proposed 358 pt, long prose is unchanged, and streaming updates stay correct.

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.

iOS: TextView collapses to its longest-line width inside flexible SwiftUI containers

1 participant