Skip to content

Show hint when label is floating #60394

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

Merged
merged 4 commits into from
Jul 2, 2020

Conversation

justinmc
Copy link
Contributor

@justinmc justinmc commented Jun 26, 2020

Description

Previously, hint wasn't showing when floatingLabelBehavior was always, even though it had room. It only showed when focused:

Screen Shot 2020-06-26 at 3 40 00 PM
Screen Shot 2020-06-26 at 3 40 05 PM

This PR makes it show even when not focused.

Related Issues

Closes #60292
Closes #53753

Tests

I added the following tests:

Render an InputDecorator with floatingLabelBehavior: FloatingLabelBehavior.always and expect the hint to be visible even when it is not focused.

@justinmc justinmc requested a review from LongCatIsLooong June 26, 2020 22:42
@justinmc justinmc self-assigned this Jun 26, 2020
@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jun 26, 2020
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

LGTM. I wasn't able to find anything on material.io that talks about this specific behavior though?

// If we're not focused, there's no value, labelText was provided, and
// floatingLabelBehavior isn't set to always, then the label appears where the
// hint would.
bool get _hasInlineLabel => !widget._labelShouldWithdraw
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the line is getting a bit too long. Maybe convert this to use curly brackets?

@flutter-github-sync
Copy link

Started Google testing for this PR

@flutter-github-sync
Copy link

Started Google testing for this PR

@flutter-github-sync
Copy link

Google testing passed!

1 similar comment
@flutter-github-sync
Copy link

Google testing passed!

@flutter-github-sync
Copy link

Started Google testing for this PR

@flutter-github-sync
Copy link

Google testing passed!

@justinmc
Copy link
Contributor Author

@LongCatIsLooong I couldn't find any specific guidelines about this behavior either. It seems weird to me that the hint would suddenly appear on focus, but I wasn't able to prove that that's what the Material spec wants either. I'll try to ask someone from Material.

@flutter-github-sync
Copy link

Started Google testing for this PR

@flutter-github-sync
Copy link

Google testing passed!

@justinmc
Copy link
Contributor Author

justinmc commented Jul 1, 2020

I'm going to move forward with this since I haven't been able to get any definitive answer from Material. My best judgement says it should work like it does in this PR. I'll be prepared to change this back if I hear otherwise.

@kelseywarshawsky
Copy link

So excited to see this :)

@justinmc justinmc deleted the hint-and-floating-label branch July 6, 2020 15:13
@diego-lipinski-de-castro

is this on stable channel yet?

@justinmc
Copy link
Contributor Author

justinmc commented Aug 5, 2020

Yes, as of the 1.20.0 release that just came out today!

mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

Hint text is not visible with FloatingLabelBehavior.always InputDecoration. Possibility to show hintText when unfocused and labelText is set
7 participants