Skip to content

Ignore collapsed children when sizing box layouts - #2990

Open
civilwarinfrance wants to merge 1 commit into
pythonarcade:developmentfrom
civilwarinfrance:fix/box-layout-collapsed-children
Open

civilwarinfrance wants to merge 1 commit into
pythonarcade:developmentfrom
civilwarinfrance:fix/box-layout-collapsed-children

Conversation

@civilwarinfrance

Copy link
Copy Markdown

Fixes #2989. A UIBoxLayout whose children all have visible=None raises ValueError while finding their minimum size. With mixed children, it also reserves gaps for collapsed widgets and leaves unused space when allocating elastic children.

Count only participating children in both sizing calculations, handle zero participants as an empty box, and invalidate the cached minimum when child visibility changes. Padding/borders and collapsed child rectangles are preserved. visible=False keeps its existing layout participation.

Added 19 regression cases covering both orientations, empty/all-collapsed boxes, before/between/after positions, actual child geometry, padding/borders, hidden controls, dynamic changes and the real UIManager lifecycle. Original code fails 13 cases; the fixed cases all pass.

Validation on macOS ARM64/Python 3.14 with the lockfile's pytest/Ruff/Mypy versions and pinned Pyright:

  • Full unit suite: 1641 passed, 9 failed. Unchanged development: 1622 passed, the same 9 failed, covering existing manager-sizing, text-rendering and HiDPI tests. No full-suite pass claimed.
  • Full Ruff lint, import sorting and formatting checks pass.
  • Mypy passes all 400 source files; Pyright reports 0 errors/warnings.
  • Whitespace check passes. Other-platform and hosted checks remain unverified.

AI assistance was used to identify, reproduce, implement and test this fix. The issue was opened before code changes, following the contribution guide.

AI-assisted implementation and testing with OpenAI Codex.

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.

UIBoxLayout crashes or reserves extra space for collapsed children

1 participant