Repository navigation
[material_ui] Hit test the floating label of InputDecorator at its painted position - #13326
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the hit testing behavior of InputDecorator for floating labels in packages/material_ui/lib/src/input_decorator.dart. When _labelTransform is not null, the paint transform is applied to the label child during hit testing, ensuring that taps target the label at its painted position. Additionally, a regression test has been added to packages/material_ui/test/input_decorator_test.dart to verify this behavior across different text directions, and a pending changelog entry has been created. There are no review comments, and I have no feedback to provide.
QuncCccccc
force-pushed
the
material-ui-label-hit-test
branch
from
November 5, 2026 20:08
225fa37 to
d238ac1
Compare
flutter-zl
pushed a commit
to NemesisDevX/flutter
that referenced
this pull request
Nov 6, 2026
flutter/packages@0478162...63881f9 2026-11-06 [email protected] [material_ui] Paint Dialog.fullscreen background color behind the keyboard (flutter/packages#13244) 2026-11-05 [email protected] [material_ui] Add tabBar/tab roles and expanded state semantics (flutter/packages#13176) 2026-11-05 [email protected] [material_ui] Disable the DropdownButtonFormField decoration when the field is disabled (flutter/packages#13473) 2026-11-05 [email protected] [material_ui] Fix Switch throwing when first painted mid-animation (flutter/packages#13496) 2026-11-05 [email protected] [various] Add engineIdentifier to fake plugin registrars (flutter/packages#13574) 2026-11-05 [email protected] [google_sign_in] Allow GoogleSignIn-iOS 10 (flutter/packages#13306) 2026-11-05 [email protected] [material_ui] Hit test the floating label of InputDecorator at its painted position (flutter/packages#13326) 2026-11-05 [email protected] [material_ui] Fix InputDecorator intrinsic height when isDense or isC… (flutter/packages#13522) 2026-11-05 [email protected] [material_ui] Paint Scaffold persistent bottom sheet background color behind the keyboard (flutter/packages#13242) 2026-11-05 [email protected] [image_picker_ios] PR 5/5 Switch Pigeon to Swift and finish the Objective-C to Swift migration. (flutter/packages#13493) 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the label of an
InputDecoratorfloats,_RenderDecoration.paintdraws the label with_labelTransform(a translation and a scale of 0.75).applyPaintTransformreports the same transform. ButhitTestChildrenhit tests the label with only its layout offset. A comment there says "The label must be handled specially since we've transformed it", but the code does not do this. Thus the label is painted in one location and hit tested in a different location:This is a problem when the label contains an interactive widget, for example a
PopupMenuButton, as in the issue. A maintainer said in the issue: "we shouldn't have weird issues with the hit testing here. Flutter should be able to do this" (comment).This change hit tests the label with the transform from
applyPaintTransformwhen_labelTransformis set. The hit test order of the children does not change. Other children keep the offset-based hit test. There is no API change.The code in
packages/flutter/lib/src/materialof flutter/flutter is frozen (see flutter/flutter#188444), so this change is only formaterial_ui.Fixes flutter/flutter#145324
Test plan
Floating label hit test matches its painted positiontotest/input_decorator_test.dart, forTextDirection.ltrandTextDirection.rtl. The test taps the painted label two times (2 taps expected), then taps 10 px below the painted label, inside its layout box (no new tap expected).Expected: <2> Actual: <0>.flutter test test/input_decorator_test.dart(+555, all passed)flutter test test/text_field_test.dart test/text_form_field_test.dart test/dropdown_menu_test.dart(all passed)flutter analyze lib/src/input_decorator.dart test/input_decorator_test.dart(no issues)dart format --output=none --set-exit-if-changed lib/src/input_decorator.dart test/input_decorator_test.dart(0 changed)Pre-Review Checklist
[shared_preferences]///).The change uses the repository's pending changelog workflow (
packages/material_ui/pending_changelogs/change_2026_10_20_floating_label_hit_test.yaml,version: patch). No public API documentation change is necessary.If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2