Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented Jan 24, 2025

Description

This PR makes InputDecorator padding for the input content, the helper and the counter compliant with the M3 spec.
The padding should be 16 pixels instead of 12 pixels (which is the current value).

See https://m3.material.io/components/text-fields/specs#0d36c3fe-7948-4ec2-ab8a-4fe39cca19cc for filled text fields and https://m3.material.io/components/text-fields/specs#605e24f1-1c1f-4c00-b385-4bf50733a5ef for outlined text fields.

Before:

The paddings for the input content, the helper and the counter are not compliant with the M3 spec (12 pixels instead of 16 pixels):

image

After:

The paddings for the input content, the helper and the counter are compliant with the M3 spec (16 pixels):

image

Related Issue

Fixes Outlined TextField Label start position doesn't meet Material Design Specs

Tests

Adds 8 tests.
Updates several tests.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jan 24, 2025
@bleroux bleroux force-pushed the make_input_decorator_horizontal_padding_compliant branch from 49426f0 to c9eb71f Compare January 24, 2025 15:03
@bleroux bleroux requested a review from justinmc January 24, 2025 15:04
@bleroux
Copy link
Contributor Author

bleroux commented Jan 24, 2025

@justinmc This PR will probably break many Google tests. It goes several step further compared to #152069 which fixed the padding when there is a prefix/suffix icon.
Here label, input, helper, error and counter paddings are changed (16 pixels instead of 12 previously). The change is limited to M3.

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.

Looks really good, I'm excited to finally fix this. The Google tests seem to not be working right now. We definitely need to trigger that and see what happens before we merge this. I'll write myself a reminder to try again later.

filteredEntries,
textDirection,
focusedIndex: currentHighlight,
useMaterial3: Theme.of(context).useMaterial3,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Maybe save this up top in a variable and reuse it (for slight performance).

: const EdgeInsetsDirectional.fromSTEB(12.0, 24.0, 12.0, 16.0));
}

double inputGap = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You could probably refactor a bit to make this final, but maybe it would be harder to read that way 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept it that way because the result of autoformat when using ternary or switch was very bad.

} else {
leadingPadding = leadingWidgetWidth;
}
leadingPadding = getWidth(_leadingKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a simplification 👍

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #162157 at sha c9eb71f

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Jan 24, 2025
@bleroux bleroux force-pushed the make_input_decorator_horizontal_padding_compliant branch from c9eb71f to 90cb865 Compare January 27, 2025 15:15
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #162157 at sha 90cb865

@justinmc
Copy link
Contributor

Goldens all look expected and I've approved them. Google tests are running.

@justinmc
Copy link
Contributor

I plan to finish verifying the Google test failures later today. At first glance everything looks as expected.

@justinmc
Copy link
Contributor

justinmc commented Feb 3, 2025

Sorry for the delay here, I'm seeing some tests where a reduced width causes text to wrap, which causes layout problems. The tests probably just need a slight tweak and I'm hoping this PR can still move forward.

@justinmc
Copy link
Contributor

I have at least one more Google customer that I need to contact about this. I will plan to look through the failing image diff tests and find which ones have layout problems in the next few days, then contact the customer.

@justinmc justinmc self-assigned this Feb 12, 2025
@justinmc
Copy link
Contributor

@bleroux Sorry I'm struggling to find the time to look into this. I'll be out next week so likely I'll get back to it after that.

@justinmc
Copy link
Contributor

I've blocked out some time for myself to look at these failures on Monday.

@justinmc
Copy link
Contributor

I'm working with a team at Google to decide on a way forward for this.

@justinmc
Copy link
Contributor

Some fields with a placeholder might be wrapping onto two lines despite having enough space to fit on one? I'm trying to come up with a minimal repro for this. Not sure if that kind of overeager wrapping should be possible with the changes in this PR or not.

@justinmc
Copy link
Contributor

justinmc commented Mar 26, 2025

I finally was able to get a good repro here! Let me know what you think @bleroux.

master this branch
master PR
Repro code
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: IntrinsicWidth(
          child: TextField(
            minLines: 1,
            maxLines: 80,
            decoration: InputDecoration(
              filled: true,
            ),
          ),
        ),
      ),
    );
  }
}

@bleroux
Copy link
Contributor Author

bleroux commented Mar 27, 2025

@justinmc Many thanks for this great repro! 🙏
I will investigate this soon.

@bleroux bleroux force-pushed the make_input_decorator_horizontal_padding_compliant branch 2 times, most recently from a951189 to c8c6aab Compare March 28, 2025 09:32
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #162157 at sha c8c6aab

@bleroux
Copy link
Contributor Author

bleroux commented Mar 28, 2025

@justinmc I updated the PR and fixed intrinsic width calculation for InputDecorator.
There was one Golden change related to time picker, I approved it as it is expected (4 pixels added at the start of the input decoration).
Let see how it goes with Google testing (the check did not run after my update).

@bleroux bleroux requested a review from justinmc March 31, 2025 08:18
@justinmc
Copy link
Contributor

justinmc commented Apr 3, 2025

Thanks for updating this. The Google tests are running 🤞

@justinmc
Copy link
Contributor

justinmc commented Apr 9, 2025

Skimming through the failures, I don't see any of the breakage that I pointed out above, but I still need to look more closely.

I do see a layout overflow due to some fields wrapping that didn't previously, though. That's probably expected, but I need to inform the customer and see what they want to do about it.

@justinmc
Copy link
Contributor

I found no more unintended test failures after skimming all of the broken tests. I'm working on fixing the layout overflow in the customer's test.

romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
)

## Description

This PR makes InputDecorator padding for the input content, the helper
and the counter compliant with the M3 spec.
The padding should be 16 pixels instead of 12 pixels (which is the
current value).

See
https://m3.material.io/components/text-fields/specs#0d36c3fe-7948-4ec2-ab8a-4fe39cca19cc
for filled text fields and
https://m3.material.io/components/text-fields/specs#605e24f1-1c1f-4c00-b385-4bf50733a5ef
for outlined text fields.

### Before:

The paddings for the input content, the helper and the counter are not
compliant with the M3 spec (12 pixels instead of 16 pixels):


![image](https://github.com/user-attachments/assets/fe74de74-6a6d-4a28-9574-a28f3e5c6084)


### After:

The paddings for the input content, the helper and the counter are
compliant with the M3 spec (16 pixels):


![image](https://github.com/user-attachments/assets/602554da-dc55-4c24-b7af-1c4951a301e9)


## Related Issue

Fixes [Outlined TextField Label start position doesn't meet Material
Design Specs](flutter#67707)

## Tests

Adds 8 tests.
Updates several tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

Development

Successfully merging this pull request may close these issues.

Outlined TextField Label start position doesn't meet Material Design Specs

2 participants