镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Adjust every paragraph style's line break mode in AttributedLabel - #629

Open
comp615 wants to merge 2 commits into
square:mainfrom
comp615:ccroom/attributed-label-mixed-paragraph-styles
Open

comp615 wants to merge 2 commits into
square:mainfrom
comp615:ccroom/attributed-label-mixed-paragraph-styles

Conversation

@comp615

@comp615 comp615 commented Nov 10, 2026

Copy link
Copy Markdown

AttributedLabel adjusts the line break mode in two places:

  • normalizingForView(with:), for display;
  • makeTextStorage(), for the layout behind link hit-testing and link frames.

Both read AttributedText.paragraphStyle, which is nil unless a single paragraph style covers the whole string. Text with several paragraph styles skipped both adjustments, for example a list where each item has its own indent:

  • On multi-line labels, the text storage kept truncating modes, including the common .byTruncatingTail, which don't work with NSTextContainer. Links after a wrapped paragraph got the wrong tap targets and accessibility frames.
  • Display normalization was skipped for .byTruncatingHead/.byTruncatingMiddle on multi-line labels, and for wrapping modes on single-line labels.

Both places now update a copy of every paragraph style range. A string with one paragraph style behaves as before.

🤖 Generated with Claude Code

comp615 and others added 2 commits November 10, 2026 16:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AttributedLabel only adjusted the line break mode when one paragraph style
covered the whole string. With more than one paragraph style (for example,
list items with their own indents), the display normalization was skipped,
and the text storage used for link hit-testing and link frames kept
truncating modes, which lay out each paragraph on a single line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@comp615
comp615 marked this pull request as ready for review November 10, 2026 21:42
@comp615
comp615 requested a review from a team as a code owner November 10, 2026 21:42

This branch has not been deployed

No deployments
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.

2 participants