Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Nov 6, 2025

Description

This PR adds InputDecorator.maintainLabelSize (similar to InputDecorator.maintainHintSize) to allow the label to be used in the intrinsic width calculation (if could be used for the intrinsic height calculation later if needed).

I opted for this flag (and defaulting to false) because changing the default calculation would probably break various usages.
See #178099 (comment) for why this change will be helpful to simplify and fix DropdownMenu implementation.

Before

The label might be cut off:

Screenshot 2025-11-05 at 20 16 43

After

The label is entirely visible because it is part of the intrinsic width calculation:

Screenshot 2025-11-05 at 20 16 09

Related Issue

Fixes TextField intrinsic width does not take label into account
Part of #123797

Tests

  • Adds 4 tests.
  • Updates 1 non-related test where I spotted some nits.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Nov 6, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new maintainLabelSize property to InputDecorator and InputDecoration. This feature allows the label's size to be included in the intrinsic width calculation, which is useful for preventing labels from being cut off, especially in widgets like DropdownMenu. The implementation is sound, adding the new flag and correctly updating the layout logic in _RenderDecoration. The changes are accompanied by a good set of tests that cover various scenarios for the new property. I found one minor issue: a typo in a test name that could be misleading. Overall, this is a great addition to improve layout control in input decorations.

@bleroux bleroux force-pushed the fix_InputDecoration_label_not_considered_intrinsic_width_calculation branch 2 times, most recently from cea25fe to 0cbac8c Compare November 6, 2025 13:46
@fluttergithubbot

This comment was marked as outdated.

@bleroux bleroux force-pushed the fix_InputDecoration_label_not_considered_intrinsic_width_calculation branch 2 times, most recently from 975d097 to f36ac99 Compare November 6, 2025 13:52
@bleroux bleroux force-pushed the fix_InputDecoration_label_not_considered_intrinsic_width_calculation branch from f36ac99 to c7a6738 Compare November 6, 2025 13:52
@bleroux bleroux requested a review from justinmc November 6, 2025 17:56
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM 👍


/// Whether the input field's size should always be greater than or equal to
/// the size of the [hintText], even if the [hintText] is not visible.
/// the size of the [hint] or [hintText], even if the [hint] or [hintText] are not visible.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call specifying both hint and hintText.

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 6, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Nov 6, 2025
Merged via the queue into flutter:master with commit 411566a Nov 7, 2025
75 of 76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 7, 2025
@bleroux bleroux deleted the fix_InputDecoration_label_not_considered_intrinsic_width_calculation branch November 7, 2025 07:17
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 12, 2025
…10408)

Manual roll requested by [email protected]

flutter/flutter@31a8481...ee23168

2025-11-07 [email protected] Roll Packages from f13bad3 to 3caa48b (5 revisions) (flutter/flutter#178164)
2025-11-07 [email protected] Fix text input actions in DropdownMenu. (flutter/flutter#177313)
2025-11-07 [email protected] Roll Skia from f838c4b31edb to 581d1ecd5029 (1 revision) (flutter/flutter#178157)
2025-11-07 [email protected] Roll Skia from eb3c5b280ae6 to f838c4b31edb (3 revisions) (flutter/flutter#178149)
2025-11-07 [email protected] Roll Skia from 360fe72b5bf4 to eb3c5b280ae6 (1 revision) (flutter/flutter#178147)
2025-11-07 [email protected] Roll Skia from 116f237bb39d to 360fe72b5bf4 (4 revisions) (flutter/flutter#178146)
2025-11-07 [email protected] Roll Fuchsia Linux SDK from cm88aTLui5yorSGYQ... to qDVe2mrpSgQdxra7p... (flutter/flutter#178144)
2025-11-07 [email protected] fix: findChildIndexCallback to take seperators into account for seperated named constructor in ListView and SliverList (flutter/flutter#174491)
2025-11-06 [email protected] [web] Remove unnecessary android_sdk dep (flutter/flutter#178078)
2025-11-06 [email protected] Add haptic notifications support. (flutter/flutter#177721)
2025-11-06 [email protected] Allow label to be used to compute InputDecorator Intrinsic width (flutter/flutter#178101)
2025-11-06 [email protected] Respect product flavor abiFilters by adding a `disable-abi-filtering` Android project flag. (flutter/flutter#177753)
2025-11-06 [email protected] Use aria-hidden attribute for platform view accessibility on web (flutter/flutter#177969)
2025-11-06 [email protected] [tool] Fix IP parsing by using Uri constructor (flutter/flutter#178083)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…tter#178101)

## Description

This PR adds `InputDecorator.maintainLabelSize` (similar to
`InputDecorator.maintainHintSize`) to allow the label to be used in the
intrinsic width calculation (if could be used for the intrinsic height
calculation later if needed).

I opted for this flag (and defaulting to false) because changing the
default calculation would probably break various usages.
See
flutter#178099 (comment)
for why this change will be helpful to simplify and fix DropdownMenu
implementation.


## Before

The label might be cut off:

<img width="126" height="71" alt="Screenshot 2025-11-05 at 20 16 43"
src="https://github.com/user-attachments/assets/61d9f817-5c58-43f9-9307-976f9c124ec7"
/>

## After

The label is entirely visible because it is part of the intrinsic width
calculation:

<img width="126" height="71" alt="Screenshot 2025-11-05 at 20 16 09"
src="https://github.com/user-attachments/assets/47360e17-3cde-4f05-8a6b-cc9e86644ffc"
/>


## Related Issue

Fixes [DropdownMenu menu panel does not close when pressing ESC and
requestFocusOnTap is
false](flutter#177993)
Part of flutter#123797
 
## Tests

- Adds 4 tests.
- Updates 1 non-related test where I spotted some nits.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…tter#178101)

## Description

This PR adds `InputDecorator.maintainLabelSize` (similar to
`InputDecorator.maintainHintSize`) to allow the label to be used in the
intrinsic width calculation (if could be used for the intrinsic height
calculation later if needed).

I opted for this flag (and defaulting to false) because changing the
default calculation would probably break various usages.
See
flutter#178099 (comment)
for why this change will be helpful to simplify and fix DropdownMenu
implementation.


## Before

The label might be cut off:

<img width="126" height="71" alt="Screenshot 2025-11-05 at 20 16 43"
src="https://github.com/user-attachments/assets/61d9f817-5c58-43f9-9307-976f9c124ec7"
/>

## After

The label is entirely visible because it is part of the intrinsic width
calculation:

<img width="126" height="71" alt="Screenshot 2025-11-05 at 20 16 09"
src="https://github.com/user-attachments/assets/47360e17-3cde-4f05-8a6b-cc9e86644ffc"
/>


## Related Issue

Fixes [DropdownMenu menu panel does not close when pressing ESC and
requestFocusOnTap is
false](flutter#177993)
Part of flutter#123797
 
## Tests

- Adds 4 tests.
- Updates 1 non-related test where I spotted some nits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextField intrinsic width does not take label into account

3 participants