-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Add 2 new keyboard types and infer keyboardType from autofill hints #56641
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
Add 2 new keyboard types and infer keyboardType from autofill hints #56641
Conversation
| /// - 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]. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
justinmc
left a comment
There was a problem hiding this 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')); | ||
| }); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]. |
There was a problem hiding this comment.
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.
ff21a3e to
b792e2e
Compare
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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".
ed44476 to
c1d7a98
Compare
c1d7a98 to
94cf7a3
Compare
dla-kirito
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to preview.
HansMuller
left a comment
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
Description
TextInputType.addressandTextInputType.name.keyboardTypefromAutofillHintsif left unspecified.engine PR: flutter/engine#18202
Related Issues
Fixes #41508
Tests
I added the following tests:
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.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.