Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented May 8, 2020

Description

  • Add TextInputType.address and TextInputType.name.
  • Infer keyboardType from AutofillHints if left unspecified.
  • Fix docs for autofillHints

engine PR: flutter/engine#18202

Related Issues

Fixes #41508

Tests

I added the following tests:

  • Infer keyboardType from autofillHints

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label May 8, 2020
/// - Some autofill hints only work with specific [keyboardType]s. For example,
/// [AutofillHints.name] requires [TextInputType.name] and [AutofillHints.email]
/// works only with [TextInputType.email]. Make sure the input field has a
/// compatible [keyboardType].
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 think the 2nd bullet point needs better documentation on which keyboard types and autofill hints are compatible. I did some tests on an iOS 13.5 device using a native app, most UITextContentType only works with UIKeyboardType.namePhonePad (which is mapped to TextInputType.name in this PR), including content types like .streetAddress, .zipCode and .telephoneNumber (despite there're more fitting keyboard types). I can't really make sense of it so I'm not sure we should put that behavior in public documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe our users should be seeking out native iOS documentation on this stuff anyway, and we should just be clear about how we map to native.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately the behavior isn't documented there either. Maybe I should change the name autofillHints to contentType to emphasize that it's not only for autofill, and it doesn't guarantee the platform autofill will trigger?

case TargetPlatform.macOS:
const Map<String, TextInputType> iOSKeyboardType = <String, TextInputType> {
AutofillHints.addressCity : TextInputType.name,
AutofillHints.addressCityAndState : TextInputType.name, // Autofill not working.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There're surprisingly many UITextContentTypes that don't trigger autofill (at least I couldn't find a way to, I had added all the fields, middle name, name prefix, etc., in Contacts). Maybe I should rename the field to textContentType?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what textContentType field you're referring to. Calling the enum that's used to select a keyboard TextInputType seems reasonable to me.

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

We should keep an eye on our issues after this is merged to see how users are understanding this.

await tester.idle();
expect(tester.testTextInput.editingState['text'], equals('test'));
expect(tester.testTextInput.setClientArgs['inputType']['name'], equals('TextInputType.address'));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Will these tests work even when they're run on other platforms after the PR is merged? I would have expected you to need to use TargetPlatformVariant, but maybe I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the looks of it, they do the same thing. Changed to TargetPlatformVariant as it seems to be more conventional.

/// - Some autofill hints only work with specific [keyboardType]s. For example,
/// [AutofillHints.name] requires [TextInputType.name] and [AutofillHints.email]
/// works only with [TextInputType.email]. Make sure the input field has a
/// compatible [keyboardType].
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe our users should be seeking out native iOS documentation on this stuff anyway, and we should just be clear about how we map to native.

@LongCatIsLooong LongCatIsLooong force-pushed the more-text-input-types branch from ff21a3e to b792e2e Compare May 8, 2020 17:44
@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. labels May 8, 2020
Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking for a better word for "availability"

Copy link
Contributor

Choose a reason for hiding this comment

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

I think availability is pretty good choice here. Alternatively you could say "how well they're supported on different platforms".

@LongCatIsLooong LongCatIsLooong force-pushed the more-text-input-types branch 2 times, most recently from ed44476 to c1d7a98 Compare May 9, 2020 07:35
@LongCatIsLooong LongCatIsLooong force-pushed the more-text-input-types branch from c1d7a98 to 94cf7a3 Compare May 9, 2020 07:36
Copy link

@dla-kirito dla-kirito left a comment

Choose a reason for hiding this comment

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

Nothing to preview.

@flutter flutter deleted a comment from dla-kirito May 29, 2020
@flutter flutter deleted a comment from dla-kirito May 29, 2020
@flutter flutter deleted a comment from dla-kirito May 29, 2020
@flutter flutter deleted a comment from dla-kirito May 29, 2020
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

case TargetPlatform.macOS:
const Map<String, TextInputType> iOSKeyboardType = <String, TextInputType> {
AutofillHints.addressCity : TextInputType.name,
AutofillHints.addressCityAndState : TextInputType.name, // Autofill not working.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what textContentType field you're referring to. Calling the enum that's used to select a keyboard TextInputType seems reasonable to me.

@fluttergithubbot fluttergithubbot merged commit b64d652 into flutter:master Jun 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository 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.

Have TextInputType.datetime use UIKeyboardType.numbersAndPunctuation on iOS

6 participants