Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase TextField's minimum height from 40 to 48 #42449

Merged
merged 13 commits into from
Nov 1, 2019

Conversation

justinmc
Copy link
Contributor

@justinmc justinmc commented Oct 10, 2019

Description

Here are some screenshots for comparison. The red square is just a Container of size 48x48 as a reference. The green is the background of the TextField.

Before After
flutter_18 flutter_15
flutter_19 flutter_16
flutter_20 flutter_21

Related Issues

Closes #41200

Tests

I added two tests to verify the minimum height is preserved for the default case and the case where text is very small. I also updated the numbers in tons of tests to reflect the new dimensions.

Breaking Change

This will break many visual diff tests due to the change in size of default TextFields and the change in the location of the baseline. I will follow the breaking changes guildelines after getting code review.

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

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

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Oct 10, 2019
@justinmc
Copy link
Contributor Author

justinmc commented Oct 15, 2019

Some things I need to check on:

  • Are outlined text fields affected by this?
    • Update: They are also limited to a minimum height of 48px. However, by default, they are already taller than this.
  • What happens if the textfield is forced to be very tall? Baseline alignment should work the same before and after this PR.
    • Update: Behavior is the same. For multiline fields, vertical alignment is set by the textAlignVertical parameter. For TextFields with no border, the default is top. With a border, the default is center. If either type of field is made very tall by setting the font size to a large value, then the text remains vertically centered.

@justinmc justinmc force-pushed the text-field-interactive-size branch from 56fed8d to bf0aca1 Compare October 17, 2019 00:05
@justinmc justinmc force-pushed the text-field-interactive-size branch from bf0aca1 to 7d53515 Compare October 17, 2019 00:05
@@ -7249,11 +7250,11 @@ void main() {

// Tap the TextField to put the cursor into it and bring it into view.
expect(scrollController.offset, 0.0);
await tester.tap(find.byType(TextField));
await tester.tapAt(tester.getTopLeft(find.byType(TextField)));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems weird... I don't know why it isn't receiving a tap with the previous line now. If anyone has a hunch please let me know.

@justinmc justinmc added c: API break Backwards-incompatible API changes will affect goldens Changes to golden files labels Oct 17, 2019
@justinmc justinmc requested a review from HansMuller October 17, 2019 18:10
@justinmc justinmc changed the title WIP TextField Interactive Size TextField Interactive Size Oct 17, 2019
@justinmc
Copy link
Contributor Author

Goldens are being updated here: flutter/goldens#58

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This looks good and its nice to see that such a big change can be accomplished with such a small change.

I think we might want to make isDense:true an exception to the min height = 48; just restore the original behavior in that case

@HansMuller HansMuller changed the title TextField Interactive Size Increase TextField's minimum height from 43 to 48 Oct 17, 2019
@jonahwilliams
Copy link
Member

This should probably utilize https://api.flutter.dev/flutter/material/MaterialTapTargetSize-class.html in some way to avoid extra padding where it doesn't matter, like desktop

@justinmc
Copy link
Contributor Author

I discussed the MaterialTapTargetSize offline and we decided to leave it out of this PR in anticipation of some upcoming work for Material.

justinmc added a commit to flutter/goldens that referenced this pull request Oct 18, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@justinmc
Copy link
Contributor Author

justinmc commented Oct 18, 2019

Draft breaking change email:

I'm proposing to increase the default height of TextField by eight pixels in order to comply with the Material spec's minimum interactive size guideline.

Issue: #41200
PR: #42449

Currently, TextFields are 40px high with default settings. This change would set a minimum height of 48px for all TextFields where the isDense flag on InputDecorator is not true. Any field whose height is calculated to be less than 48px would be bumped up to 48 and its content vertically centered. Smaller TextFields could still be created with the isDense flag set to true.

Anyone that currently has a TextField that is below 48px high in their app, including those just using the default TextField settings, will see the size of these fields increase. These affected apps will need to update any visual diff tests covering these fields, and may also need to adjust their layouts to accommodate the larger fields.

If someone wishes to keep their TextFields at a height of less than 48px, they may do so by using the isDense flag. As a specific example, the following code will create a TextField that is still the original default height of 40px:

TextField(
style: TextStyle(height: 1.5),
decoration: InputDecoration(isDense: true),
)

Please let me know if you have any trouble migrating and need some help! I'm reachable at this email address or on Github in the given PR (@justinmc).

If anyone objects to this change or would like to discuss further, please comment in the linked PR.

Thanks,

Justin

@HansMuller HansMuller changed the title Increase TextField's minimum height from 43 to 48 Increase TextField's minimum height from 40 to 48 Oct 21, 2019
@justinmc
Copy link
Contributor Author

@Piinks If I still see goldens failures after merging my goldens PR, does that mean it's my fault and the goldens I added don't match?

Sorry, I'm forgetting if there's anything else I need to do to update the goldens here.

@Piinks
Copy link
Contributor

Piinks commented Oct 23, 2019

Have the version numbers been incremented to match the golden file changes?

@justinmc
Copy link
Contributor Author

That's it, I knew I forgot something. Thank you!

@justinmc justinmc requested a review from Piinks as a code owner October 23, 2019 17:49
@Piinks
Copy link
Contributor

Piinks commented Oct 28, 2019

#43371 has changed golden file testing, which will need a few minor adjustments here. When you resolve the merge conflicts, the goldens.version file will no longer exist.
It looks like this change affects already existing tests, so in order for them to pass pre-submit here, an ignore will have to be put in place for the affected tests in Flutter Gold.
As far as I can tell it looks like the affected tests are

  • text_field_cursor_test.material.0
  • text_field_cursor_test.material.1
  • text_field_opacity_test.0

Take a look at the updated Writing a golden file test for package:flutter, and let me know if I can help migrate this change to the new system. :)

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

@Piinks
Copy link
Contributor

Piinks commented Oct 29, 2019

Can we wait to land this until tomorrow?

  • The duration of the ignore should be set to cover the amount of time it will take to be triaged. Feel free to edit it to something conservative (a day or two is totally fine).

Also, there are performance improvements that should land by tomorrow AM that will make for a much better experience landing this:

@justinmc
Copy link
Contributor Author

Yeah that's fine with me! This PR has a breaking change so I don't want to rush it anyway. I will hold off until tomorrow. I've updated the expiration to 2 days.

@Piinks
Copy link
Contributor

Piinks commented Oct 31, 2019

Gold updates have landed, and I renewed the ignore on the dashboard. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: API break Backwards-incompatible API changes 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
None yet
Development

Successfully merging this pull request may close these issues.

TextFields don't meet minimum accessibility height (48 px) with default style (just 43)
6 participants