Skip to content

fix: keep annotation label text visible on styles that collapse the text sub-rect - #2273

Merged
wkentaro merged 1 commit into
mainfrom
fix/1228-label-text-clipping
Jul 1, 2026
Merged

wkentaro merged 1 commit into
mainfrom
fix/1228-label-text-clipping

Conversation

@wkentaro

@wkentaro wkentaro commented Jul 1, 2026

Copy link
Copy Markdown
Owner

HTMLDelegate.paint empties opt.text before asking the style for the text sub-rect via subElementRect(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 on main and passing here
  • uv run pytest tests/ — full suite green (703 passed)
  • uv run ruff format --check && uv run ruff check && uv run ty check — clean
  • Real-widget render smoke: LabelListWidget populated with real shape labels renders without clipping or crash

…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
@wkentaro wkentaro self-assigned this Jul 1, 2026
@wkentaro wkentaro added this to the v7.0.0 milestone Jul 1, 2026
@wkentaro

wkentaro commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

This was generated by AI during PR processing.

Verdict: recommend-merge

Finalized this tick:

  • Rebase: not needed — branch sits exactly at current main (zero divergence), so the green CI already reflects the merged result.
  • Review gate: /code-review (medium) over the diff found no meaningful issues. The one substantive line widens the delegate's text sub-rect to ceil(doc.idealWidth()) before it becomes the clip rect, so styles (e.g. Adwaita/GNOME) that return a collapsed sub-rect no longer clip the label; max() leaves normal styles untouched. Single-column list, so no adjacent-column overflow.
  • History: single, well-formed commit — nothing to reshape.
  • CI: all 8 test matrix jobs + lint green. No push this tick, so the existing checks are authoritative.
  • Test: the new characterization test (label_list_widget_test.py) reproduces the collapsed-sub-rect case and passes locally.

Ready for maintainer merge.

@wkentaro wkentaro added the recommend-merge pr: Agent finalized and endorses it: review and merge label Jul 1, 2026
@wkentaro
wkentaro merged commit f8dd63c into main Jul 1, 2026
8 checks passed
@wkentaro
wkentaro deleted the fix/1228-label-text-clipping branch July 1, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recommend-merge pr: Agent finalized and endorses it: review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrectly clipped polygon labels item text

1 participant