GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [material_ui] Fix MenuAnchor scrollbar safe-area padding by abdullahtas0 · Pull Request #12470 · flutter/packages Conversation
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pull request prevents MenuAnchor scrollbars from inheriting system safe-area padding by removing padding from the MediaQuery surrounding the Scrollbar and restoring it for the inner scroll view. A regression test and a changelog entry are also included. The feedback suggests optimizing the implementation by using mediaQuery.removePadding(...) directly on the already retrieved MediaQueryData instance, avoiding redundant MediaQuery.of(context) lookups.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| final EdgeInsetsGeometry padding = | ||
| resolve<EdgeInsetsGeometry?>((MenuStyle? style) => style?.padding) ?? EdgeInsets.zero; | ||
| final Offset densityAdjustment = visualDensity.baseSizeAdjustment; | ||
| final MediaQueryData mediaQuery = MediaQuery.of(context); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Removing the system padding for just the scrollbar looks good to me. To make it clear why we are doing so, do you mind adding a comment here and renaming the two MediaQuery instances to something like ambientMediaQuery and scrollbarMediaQuery?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done. Added a comment explaining why the padding is dropped for the scrollbar, and renamed the values to ambientMediaQuery and scrollbarMediaQuery.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| testWidgets('Menu scrollbar does not inherit MediaQuery padding', (WidgetTester tester) async { | ||
| addTearDown(tester.view.reset); | ||
| tester.view.devicePixelRatio = 1.0; | ||
| tester.view.padding = const FakeViewPadding(bottom: 24.0); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe add padding on all four sides to verify they are all removed for the scrollbar but retained on menuItemPadding.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done. The view padding is now FakeViewPadding(left: 8, top: 16, right: 32, bottom: 24), and the test asserts scrollbarPainter.padding is EdgeInsets.zero while menuItemPadding is still EdgeInsets.fromLTRB(8, 16, 32, 24). Without the source change the painter padding comes back as EdgeInsets(8.0, 16.0, 32.0, 24.0).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| }, variant: TargetPlatformVariant.desktop()); | ||
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/188155. | ||
| testWidgets('Menu scrollbar does not inherit MediaQuery padding', (WidgetTester tester) async { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Consider testing that we can scroll all the way to the bottom as well since the issue mentions the scrollbar getting stuck there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done. The test now drags the menu to the end and asserts position.pixels == position.maxScrollExtent, then checks that the painted thumb ends at the bottom of the scrollbar box. I verified that last assertion is not vacuous: with the source change reverted it fails on its own, because the track stops 24 logical pixels short and the thumb never reaches the end.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3db34ec to
bdc4cc4
Compare
There was an error while loading. Please reload this page.
|
Thanks for the review @elliette — all three comments are addressed, and the branch is rebased onto current Validation on the new head:
Reverting only the One note on CI: the only red job on the previous run was The push also cleared the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // Material's Scrollbar uses the ambient MediaQuery padding as its painter | ||
| // padding when no explicit padding is given, so that the thumb clears | ||
| // system intrusions such as a gesture bar. The menu overlay is already | ||
| // positioned inside the safe area, so honoring that padding a second time | ||
| // shortens the scrollbar track and stops the thumb from reaching the end of | ||
| // the menu. The padding is therefore removed for the Scrollbar only and | ||
| // restored below it, so menu children keep observing the ambient values. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| // Material's Scrollbar uses the ambient MediaQuery padding as its painter | |
| // padding when no explicit padding is given, so that the thumb clears | |
| // system intrusions such as a gesture bar. The menu overlay is already | |
| // positioned inside the safe area, so honoring that padding a second time | |
| // shortens the scrollbar track and stops the thumb from reaching the end of | |
| // the menu. The padding is therefore removed for the Scrollbar only and | |
| // restored below it, so menu children keep observing the ambient values. | |
| // Scrollbar uses the `MadiaQuery.padding` as its painter | |
| // padding by default. Menu overlays are already | |
| // positioned within the safe area, so applying that padding again | |
| // shortens the scrollbar track and stops the thumb from reaching the end of | |
| // the menu. Remove the padding only for the Scrollbar and restore the ambient MediaQuery for menu children. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I left the existing comment in place: this wording uses MadiaQuery, and the current comment already explains why the padding is removed only for the scrollbar.
I did not push a follow-up. This head is approved with green CI, and a new push clears the CICD label, which I cannot restore. Happy to apply a corrected comment if you want that wording — it would need CICD added again. Otherwise this looks ready to land.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please update the comment to reflect @QuncCccccc's suggestion. MadiaQuery is a typo, it should be MediaQuery. We will re-add the CICD label after.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in 0f6d17b — the comment now uses @QuncCccccc's wording, with the typo fixed to MediaQuery.padding and the lines rewrapped to 80 columns. No code changes; menu_anchor_test.dart still passes (171 passed, 1 skipped) and dart format / flutter analyze are clean.
Thanks for re-adding CICD!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Explain why the menu Scrollbar drops the ambient MediaQuery padding and name the two MediaQueryData values after their roles. Extend the regression test to pad all four sides, and assert that the menu still scrolls to the very bottom with the scrollbar thumb reaching the end of its track.
0f6d17b to
f304493
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience! Looks good
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
flutter/packages@93baed9...108dad0 2026-10-22 [email protected] [material_ui] Migrate M3 IconButton template to use new gen_defaults (flutter/packages#12922) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationBar template to use new gen_defaults (flutter/packages#13067) 2026-10-22 [email protected] [material_ui] Remove obsolete `SurfaceTint` defaults template (flutter/packages#13276) 2026-10-22 [email protected] [material_ui] Migrate M3 Radio template to use new gen_defaults (flutter/packages#13210) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationDrawer template to use new gen_defaults (flutter/packages#13068) 2026-10-22 [email protected] [image_picker_ios] PR 3/5 Split SPM packaging and migrate the plugin class to Swift (flutter/packages#13235) 2026-10-22 [email protected] [ci] Increase check-discovery timeout in release workflows (flutter/packages#13392) 2026-10-22 [email protected] [material_ui] Migrate M3 `Switch` template to use new gen_defaults (flutter/packages#13274) 2026-10-22 [email protected] [material_ui] Migrate M3 PopupMenu template to use new gen_defaults (flutter/packages#13209) 2026-10-22 [email protected] [material_ui] Add day and weekday builders to CalendarDatePicker and showDatePicker (flutter/packages#12587) 2026-10-22 [email protected] [material_ui] Migrate M3 `SearchView` template to use new gen_defaults (flutter/packages#13272) 2026-10-22 [email protected] [material_ui] Migrate M3 `TextField` template to use new gen_defaults (flutter/packages#13275) 2026-10-22 [email protected] [material_ui] Migrate M3 RangeSlider template to use new gen_defaults (flutter/packages#13215) 2026-10-22 [email protected] [go_router] Keep web autocomplete focused in shell routes (flutter/packages#13348) 2026-10-22 [email protected] [shared_preferences_android] Fix web compilation of apps that import the package (flutter/packages#13380) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationRail template to use new gen_defaults (flutter/packages#13069) 2026-10-22 [email protected] [material_ui] Migrate M3 SearchBar template to use new gen_defaults (flutter/packages#13216) 2026-10-22 [email protected] [material_ui] Fix for time picker error in locales that do not use Latin digits (flutter/packages#13035) 2026-10-22 [email protected] [material_ui] Fix MenuAnchor scrollbar safe-area padding (flutter/packages#12470) 2026-10-22 [email protected] [material_ui] Document Material 3 fallback for Divider.color and VerticalDivider.color (flutter/packages#12967) 2026-10-22 [email protected] [material_ui] Migrate M3 tabs template to use new gen_defaults (flutter/packages#13139) 2026-10-22 [email protected] [material_ui] Migrate M3 progress indicator defaults to new gen_defaults (flutter/packages#13026) 2026-10-22 [email protected] [google_sign_in] Convert the iOS example app and UI tests to Swift (flutter/packages#13271) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@93baed9...108dad0 2026-10-22 [email protected] [material_ui] Migrate M3 IconButton template to use new gen_defaults (flutter/packages#12922) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationBar template to use new gen_defaults (flutter/packages#13067) 2026-10-22 [email protected] [material_ui] Remove obsolete `SurfaceTint` defaults template (flutter/packages#13276) 2026-10-22 [email protected] [material_ui] Migrate M3 Radio template to use new gen_defaults (flutter/packages#13210) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationDrawer template to use new gen_defaults (flutter/packages#13068) 2026-10-22 [email protected] [image_picker_ios] PR 3/5 Split SPM packaging and migrate the plugin class to Swift (flutter/packages#13235) 2026-10-22 [email protected] [ci] Increase check-discovery timeout in release workflows (flutter/packages#13392) 2026-10-22 [email protected] [material_ui] Migrate M3 `Switch` template to use new gen_defaults (flutter/packages#13274) 2026-10-22 [email protected] [material_ui] Migrate M3 PopupMenu template to use new gen_defaults (flutter/packages#13209) 2026-10-22 [email protected] [material_ui] Add day and weekday builders to CalendarDatePicker and showDatePicker (flutter/packages#12587) 2026-10-22 [email protected] [material_ui] Migrate M3 `SearchView` template to use new gen_defaults (flutter/packages#13272) 2026-10-22 [email protected] [material_ui] Migrate M3 `TextField` template to use new gen_defaults (flutter/packages#13275) 2026-10-22 [email protected] [material_ui] Migrate M3 RangeSlider template to use new gen_defaults (flutter/packages#13215) 2026-10-22 [email protected] [go_router] Keep web autocomplete focused in shell routes (flutter/packages#13348) 2026-10-22 [email protected] [shared_preferences_android] Fix web compilation of apps that import the package (flutter/packages#13380) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationRail template to use new gen_defaults (flutter/packages#13069) 2026-10-22 [email protected] [material_ui] Migrate M3 SearchBar template to use new gen_defaults (flutter/packages#13216) 2026-10-22 [email protected] [material_ui] Fix for time picker error in locales that do not use Latin digits (flutter/packages#13035) 2026-10-22 [email protected] [material_ui] Fix MenuAnchor scrollbar safe-area padding (flutter/packages#12470) 2026-10-22 [email protected] [material_ui] Document Material 3 fallback for Divider.color and VerticalDivider.color (flutter/packages#12967) 2026-10-22 [email protected] [material_ui] Migrate M3 tabs template to use new gen_defaults (flutter/packages#13139) 2026-10-22 [email protected] [material_ui] Migrate M3 progress indicator defaults to new gen_defaults (flutter/packages#13026) 2026-10-22 [email protected] [google_sign_in] Convert the iOS example app and UI tests to Swift (flutter/packages#13271) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Scrollbar of MenuAnchor works incorrectly
There was an error while loading. Please reload this page.