Fix RenderFlex overflow in debugging controls at narrow widths - #9949
Fix RenderFlex overflow in debugging controls at narrow widths#9949theprantadutta wants to merge 3 commits into
Conversation
The debugging controls drop their button labels below DebuggingControls.minWidth, but the remaining icon-only content still does not fit below roughly 630px, so the controls Row overflowed at widths that are realistic for DevTools embedded in an IDE side panel. Make the controls scroll horizontally so every control stays reachable instead of being clipped behind an overflow error. The file explorer button stays pinned outside the scroll view so it does not scroll out of reach, which keeps the wide layout visually unchanged. Fixes flutter#4917
There was a problem hiding this comment.
Code Review
This pull request introduces horizontal scrolling to the debugging controls in the debugger screen to prevent layout overflow on narrow screens, such as when DevTools is embedded in an IDE side panel. It also adds a corresponding release note and a new test suite to verify the layout behavior at various widths. The review feedback suggests moving the initialization of stateful mocks, controllers, and global services in the new test file into a setUp block to avoid potential test pollution and flakiness.
| final fakeServiceConnection = FakeServiceConnectionManager(); | ||
| final scriptManager = MockScriptManager(); | ||
| mockConnectedApp(fakeServiceConnection.serviceManager.connectedApp!); | ||
| setGlobal(ServiceConnectionManager, fakeServiceConnection); | ||
| setGlobal(IdeTheme, IdeTheme()); | ||
| setGlobal(ScriptManager, scriptManager); | ||
| setGlobal(NotificationService, NotificationService()); | ||
| setGlobal(BreakpointManager, BreakpointManager()); | ||
| setGlobal( | ||
| DevToolsEnvironmentParameters, | ||
| ExternalDevToolsEnvironmentParameters(), | ||
| ); | ||
| setGlobal(PreferencesController, PreferencesController()); | ||
| fakeServiceConnection.consoleService.ensureServiceInitialized(); | ||
| when( | ||
| fakeServiceConnection.errorBadgeManager.errorCountNotifier('debugger'), | ||
| ).thenReturn(ValueNotifier<int>(0)); | ||
| final debuggerController = createMockDebuggerControllerWithDefaults(); |
There was a problem hiding this comment.
[CONCERN] Stateful mocks, controllers, and global services should be initialized inside a setUp block rather than at the top level of main(). When initialized at the top level of main(), they are shared across all tests in the file, which can lead to test pollution, side effects, and flakiness if one test modifies their state.
late FakeServiceConnectionManager fakeServiceConnection;
late MockScriptManager scriptManager;
late MockDebuggerController debuggerController;
setUp(() {
fakeServiceConnection = FakeServiceConnectionManager();
scriptManager = MockScriptManager();
mockConnectedApp(fakeServiceConnection.serviceManager.connectedApp!);
setGlobal(ServiceConnectionManager, fakeServiceConnection);
setGlobal(IdeTheme, IdeTheme());
setGlobal(ScriptManager, scriptManager);
setGlobal(NotificationService, NotificationService());
setGlobal(BreakpointManager, BreakpointManager());
setGlobal(
DevToolsEnvironmentParameters,
ExternalDevToolsEnvironmentParameters(),
);
setGlobal(PreferencesController, PreferencesController());
fakeServiceConnection.consoleService.ensureServiceInitialized();
when(
fakeServiceConnection.errorBadgeManager.errorCountNotifier('debugger'),
).thenReturn(ValueNotifier<int>(0));
debuggerController = createMockDebuggerControllerWithDefaults();
});References
- Categorize Severity: Prefix every comment with a severity: [CONCERN] for maintainability issues. (link)
Fixes #4917
The debugging controls already drop their button labels below
DebuggingControls.minWidth, but there is no strategy left once the icon-only content itself does not fit, so the controlsRowoverflows. The 2022 report was at a wider width; the small-mode work since then fixed the common case but not the narrow one.I measured the current threshold by pumping
DebuggingControlsthrough the repo's test harness at descending window widths onmaster:So it starts at roughly 630px, which is realistic for DevTools embedded in an IDE side panel.
The change
The controls now scroll horizontally instead of overflowing, so every control stays reachable at any width rather than being clipped behind an overflow error. The file explorer button stays pinned outside the scroll view so it does not scroll out of reach, which keeps the wide layout visually unchanged.
In #4917 @kenzieschmoll suggested merging the pause/resume buttons, densifying the stepping group, or shrinking the exceptions dropdown font. I went with scrolling because it is the least invasive of the options I proposed on the issue and it holds at any width rather than buying back a fixed number of pixels — but I'm happy to switch to a denser layout, or combine the two, if you'd prefer that direction.
Before / after at 500px
Before:
After:
These are widget-test captures rather than app screenshots, so text renders as solid bars in the test font — the relevant part is the overflow striping on the right edge in the "before" image, and the file explorer button being visible and pinned in the "after" image.
Tests
Added
debugger_controls_overflow_test.dart, which pumps the controls at each of the widths above and asserts no exception, plus one test pinning the file explorer button to the right edge so the wide layout does not silently regress. I confirmed the test fails on the three narrow widths without the fix and passes with it.test/screens/debugger/andscaffold_debugging_controls_test.dartotherwise pass. One unrelated pre-existing failure indebugger_evaluation_test.dart("EvalOnDartLibrary returns no operators for int") reproduces on a cleanmastercheckout without my change.Pre-launch Checklist
General checklist
///).Issues checklist
contributions-welcomeorgood-first-issuelabel.contributions-welcomeorgood-first-issuelabel. I understand this means my PR might take longer to be reviewed.Tests checklist
AI-tooling checklist
Feature-change checklist
release-notes-not-requiredlabel or left a comment requesting the label be added.packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.On that last box: I verified this through widget tests and the rendered captures above rather than by running the DevTools app against a live VM service, so I've left it unchecked rather than tick something I didn't do. If you'd like a manual pass against a running app before this lands, say the word and I'll do that.