fix: keep annotation label text visible on styles that collapse the text sub-rect - #2273
Merged
Merged
Conversation
…ub-rect The HTMLDelegate empties opt.text before measuring the text sub-rect via subElementRect, so some styles (e.g. GNOME/Adwaita) return a rect too narrow for the rendered HTML and clip the label. Widen the clip rect to the document's ideal width so the text stays visible on all styles. Closes #1228
Owner
Author
Verdict: Finalized this tick:
Ready for maintainer merge. |
This was referenced Jul 1, 2026
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.
HTMLDelegate.paintemptiesopt.textbefore asking the style for the text sub-rect viasubElementRect(SE_ItemViewItemText, ...), so some desktop styles (e.g. GNOME/Adwaita) return a rect too narrow for the rendered HTML and clip the annotation label — on some setups making the text practically invisible. The fix widens the clip rect to the document's ideal width (max(width, ceil(doc.idealWidth()))), so it can only grow, never shrink a rect a well-behaved style already sized correctly.The bug is style-dependent and can't be reproduced on this platform, so the regression test forces the same condition deterministically: it renders the delegate with a collapsed text sub-rect and asserts the label ink is drawn past the collapsed width instead of being clipped away (red on
main, green here).Closes #1228
Test plan
tests/unit/widgets/label_list_widget_test.py— new test, verified failing onmainand passing hereuv run pytest tests/— full suite green (703 passed)uv run ruff format --check && uv run ruff check && uv run ty check— cleanLabelListWidgetpopulated with real shape labels renders without clipping or crash