Skip to content

Keep a dialog with no buttons measurable - #158

Merged
Oleg-Melnik merged 5 commits into
masterfrom
fix-dialog-layout-crash
Aug 5, 2026
Merged

Keep a dialog with no buttons measurable#158
Oleg-Melnik merged 5 commits into
masterfrom
fix-dialog-layout-crash

Conversation

@Oleg-Melnik

@Oleg-Melnik Oleg-Melnik commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes #156.

Dialog.buttonsSection() placed the buttons into a row measured with
IntrinsicSize.Max and spaced with Look.buttonsSpacing. Such a row reports an
intrinsic width of sum(children) + spacing * (children - 1), which with no
children is minus the spacing, and the negative width fails the measure pass. A
dialog that opted into neither the Submit nor the Cancel button therefore crashed
whenever its width was left as Dp.Unspecified, since that is what makes the
window measure the content intrinsically.

The buttons section is now skipped altogether when the dialog has opted into
neither button, so nothing is measured in that case. Dialogs that do display one
or both buttons keep their current spacing and layout.

Tests

DialogSizingSpec gains two cases, backed by a minimal TestDialog fixture:

  • measure a dialog that displays no buttons — reproduces the crash; it fails
    without the fix.
  • keep the spacing between the buttons that a dialog displays — pins the
    spacing of a two-button and a single-button section against the same sections
    measured with zero spacing.

Oleg-Melnik and others added 3 commits August 5, 2026 13:44
`Dialog.buttonsSection()` placed the buttons into a row spaced with
`Look.buttonsSpacing`, and such a row reports an intrinsic width of minus
that spacing when it has no children. A dialog that opted into neither
the Submit nor the Cancel button therefore failed the measure pass
whenever its `width` was left unspecified. The section is now skipped
altogether in that case, leaving the spacing of the dialogs that do
display their buttons intact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Oleg-Melnik
Oleg-Melnik requested review from armiol and dpikhulya August 5, 2026 10:54
@Oleg-Melnik Oleg-Melnik changed the title Keep a dialog with no buttons measurable. Keep a dialog with no buttons measurable Aug 5, 2026
@Oleg-Melnik
Oleg-Melnik merged commit e52e9d5 into master Aug 5, 2026
5 checks passed
@Oleg-Melnik
Oleg-Melnik deleted the fix-dialog-layout-crash branch August 5, 2026 12:32
@Oleg-Melnik Oleg-Melnik self-assigned this Aug 5, 2026
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.

Dialog with no buttons crashes when its width is measured intrinsically

2 participants