Skip to content

Fix form sheet buttons pushed off screen#155

Merged
phanan merged 2 commits into
masterfrom
fix/form-sheet-buttons
Mar 29, 2026
Merged

Fix form sheet buttons pushed off screen#155
phanan merged 2 commits into
masterfrom
fix/form-sheet-buttons

Conversation

@phanan
Copy link
Copy Markdown
Member

@phanan phanan commented Mar 29, 2026

Summary

  • SizedBox(height: 85%) forced the sheet to always be tall, and Expanded on the scroll area consumed all remaining space, pushing Cancel/Create buttons below the visible area
  • Changed to ConstrainedBox(maxHeight: 85%) so the sheet sizes to its content
  • Changed Expanded to Flexible so the scroll area only takes what it needs

Affects all form sheets: New Playlist, Create Folder, Add/Edit Radio Station.

Test plan

  • Open New Playlist sheet — verify Cancel and Create buttons are visible
  • Open Add Radio Station sheet (more fields) — verify buttons are visible
  • With keyboard open, verify buttons remain accessible
  • Run flutter test

Summary by CodeRabbit

  • New Features

    • Form sheets now use flexible height constraints (up to 85% of screen height) instead of fixed sizing, enabling better responsiveness and improved scrolling behavior across various device sizes and screen orientations.
  • Tests

    • Added comprehensive widget tests to validate form sheet functionality, including button placement verification and submit callback behavior.

Use ConstrainedBox with maxHeight instead of fixed SizedBox height so
the sheet sizes to content. Use Flexible instead of Expanded for the
scroll area so it only takes what it needs, keeping buttons visible.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

The showFormSheet widget's layout was refactored to use a constraint-based approach with ConstrainedBox (maxHeight at 85% of screen) instead of fixed-height SizedBox, and the scrollable content region changed from Expanded to Flexible. Comprehensive widget tests were added to validate button placement and callback behavior.

Changes

Cohort / File(s) Summary
Form Sheet Layout Refactoring
lib/ui/widgets/form_sheet.dart
Changed bottom sheet child from fixed SizedBox height to ConstrainedBox with 85% screen height constraint. Replaced Expanded with Flexible in scrollable content region for more flexible layout behavior.
Form Sheet Widget Tests
test/ui/widgets/form_sheet_test.dart
Added new test suite with three scenarios: verifying action buttons exist and remain within screen bounds, and validating onSubmit callback execution on button tap.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 The form sheets grow with flexible grace,
No rigid heights to bound the space—
Eighty-five percent, the walls now bend,
And tests ensure buttons won't transcend!
Hop and scroll with newfound ease!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix form sheet buttons pushed off screen' directly and clearly describes the main issue being fixed—form sheet buttons being pushed below the visible area. It matches the primary change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/form-sheet-buttons

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Verify buttons are within the visible viewport for both short forms
(few fields) and tall forms (many fields), and that the submit button
is tappable.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/ui/widgets/form_sheet_test.dart (1)

11-134: Add a keyboard-inset regression test.

The suite is strong, but it currently misses the keyboard-open case from the PR objective. Please add a test that simulates non-zero bottom viewInsets and re-checks that Cancel/Submit remain accessible.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/ui/widgets/form_sheet_test.dart` around lines 11 - 134, Add a new
testWidgets named like 'buttons are visible with keyboard open' that uses
buildTestApp and showFormSheet and simulates a non-zero bottom keyboard inset by
setting the test binding window viewInsetsTestValue (e.g.
TestWidgetsFlutterBinding.instance.window.viewInsetsTestValue or
tester.binding.window.viewInsetsTestValue) to a bottom inset before pumping the
widget, then pumpAndSettle, assert Cancel and Submit (or the submitLabel used)
are present and their rect.bottom is within the visible screen bounds, and
finally reset the viewInsetsTestValue to EdgeInsets.zero (or clear the test
value) after the test so other tests are unaffected; keep references to
showFormSheet, buildTestApp, and the binding/window viewInsets test value in the
test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/ui/widgets/form_sheet.dart`:
- Around line 21-24: The Column inside the FormSheet's build (inside the
ConstrainedBox that sets maxHeight using MediaQuery) is using the default
mainAxisSize which forces it to expand; update that Column widget to include
mainAxisSize: MainAxisSize.min so it will shrink-to-fit its children within the
ConstrainedBox instead of always filling the max height.

---

Nitpick comments:
In `@test/ui/widgets/form_sheet_test.dart`:
- Around line 11-134: Add a new testWidgets named like 'buttons are visible with
keyboard open' that uses buildTestApp and showFormSheet and simulates a non-zero
bottom keyboard inset by setting the test binding window viewInsetsTestValue
(e.g. TestWidgetsFlutterBinding.instance.window.viewInsetsTestValue or
tester.binding.window.viewInsetsTestValue) to a bottom inset before pumping the
widget, then pumpAndSettle, assert Cancel and Submit (or the submitLabel used)
are present and their rect.bottom is within the visible screen bounds, and
finally reset the viewInsetsTestValue to EdgeInsets.zero (or clear the test
value) after the test so other tests are unaffected; keep references to
showFormSheet, buildTestApp, and the binding/window viewInsets test value in the
test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a91756ec-2601-4073-b832-664fb1c19ac0

📥 Commits

Reviewing files that changed from the base of the PR and between 14060c1 and 51c24b9.

📒 Files selected for processing (2)
  • lib/ui/widgets/form_sheet.dart
  • test/ui/widgets/form_sheet_test.dart

Comment on lines +21 to +24
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.85,
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's find and examine the form_sheet.dart file
fd form_sheet.dart

Repository: koel/player

Length of output: 85


🏁 Script executed:

# Read the form_sheet.dart file to examine the code structure
cat -n lib/ui/widgets/form_sheet.dart

Repository: koel/player

Length of output: 11405


Add mainAxisSize: MainAxisSize.min to the Column to enable shrink-to-content behavior.

The ConstrainedBox sets a maximum height constraint, but the Column at line 71 uses the default mainAxisSize: MainAxisSize.max, which causes it to expand to the full 85% height even for short forms. Without mainAxisSize: MainAxisSize.min, the sheet will remain unnecessarily tall.

Suggested fix
             return Column(
+              mainAxisSize: MainAxisSize.min,
               crossAxisAlignment: CrossAxisAlignment.stretch,
               children: [
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/ui/widgets/form_sheet.dart` around lines 21 - 24, The Column inside the
FormSheet's build (inside the ConstrainedBox that sets maxHeight using
MediaQuery) is using the default mainAxisSize which forces it to expand; update
that Column widget to include mainAxisSize: MainAxisSize.min so it will
shrink-to-fit its children within the ConstrainedBox instead of always filling
the max height.

@phanan phanan merged commit db4ab54 into master Mar 29, 2026
2 checks passed
@phanan phanan deleted the fix/form-sheet-buttons branch March 29, 2026 16:31
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.

1 participant