Skip to content

Fix ComboBox single-item dropdown crash on open - #1347

Merged
bdlukaa merged 3 commits into
masterfrom
copilot/fix-combobox-error-single-item
Aug 2, 2026
Merged

Fix ComboBox single-item dropdown crash on open#1347
bdlukaa merged 3 commits into
masterfrom
copilot/fix-combobox-error-single-item

Conversation

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Opening a ComboBox with exactly one item could throw Invalid argument(s): 0.0 from clamp-bound calculations during menu clip/paint animation. This regressed behavior that previously worked and was triggered by single-item dropdown geometry.

  • Root cause + guardrails in menu geometry

    • Updated clamp bound math in combo_box.dart to ensure lower/upper bounds are always valid when menu height is smaller than one item during transition frames.
    • Applied the same bound normalization in both:
      • _ComboBoxResizeClipper.getClip
      • _ComboBoxMenuPainter.paint
    • This keeps clip and paint paths consistent and prevents double.clamp from receiving inverted bounds.
  • Regression coverage

    • Added a focused widget test in test/combo_box_test.dart that opens a one-item ComboBox and asserts no exception is produced.
  • Changelog

    • Added a [next] entry documenting the single-item ComboBox crash fix.
final maxTopOffset = math.max(0.0, size.height - kComboBoxItemHeight);
final minBottomOffset = math.min(kComboBoxItemHeight, size.height);

final top = selectedItemOffset.clamp(0.0, maxTopOffset);
final bottom = (top + kComboBoxItemHeight).clamp(minBottomOffset, size.height);

Copilot AI changed the title [WIP] Fix error in ComboBox with only one item Fix ComboBox single-item dropdown crash on open Aug 2, 2026
Copilot AI requested a review from bdlukaa August 2, 2026 22:36
@bdlukaa
bdlukaa marked this pull request as ready for review August 2, 2026 22:38
@bdlukaa
bdlukaa merged commit d84f358 into master Aug 2, 2026
3 checks passed
@bdlukaa
bdlukaa deleted the copilot/fix-combobox-error-single-item branch August 3, 2026 11:18
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.

🐛 Combobox with only one item raises error when clicked

2 participants