Autofilling an email to a UITextField with UITextContentType of email doesn't send correct information to UITextFieldDelegate shouldChangeCharactersInRange function
| Originator: | aaron | ||
| Number: | rdar://33634848 | Date Originated: | 7/31/2017 |
| Status: | Open | Resolved: | |
| Product: | UIKit | Product Version: | iOS 11 Beta 4 |
| Classification: | Bug | Reproducible: | Always |
Summary: I have a UITextField, it's textContentType is set to UITextContentType.emailAddress and when the field is selected, email addresses are properly shown above the keyboard. However I have a limited set of characters allowed in this UITextField and that is gated by the textfield's delegate implementing textField:shouldChangeCharacterIn:replacementString. One of those invalid characters is a space. Unfortunately, when tapping the suggested email address above the keyboard, the replacementString sent to the delegate function is " " and not "the@email.address". Also what is finally inserted is "the@email.address " with a trailing space at the end. This functionality makes it challenging to validate input and also erroneously inserts spaces after an email address in a field designated only for email addresses. Steps to Reproduce: 1. Create a UITextField 2. Set the text field's textContentType to .emailAddress 3. Set its delegate 4. Implement func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool in the delegate 4. Select the text field 5. Try to insert the suggested email address 6. Note that the string sent to func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool is " " and not the email address. Expected Results: Should receive the actual email address in the delegate function without a trailing space. Observed Results: The delegate function is told that a single space is attempting to be inserted, then if it returns true, the email address plus a space is inserted, if it returns false, nothing is inserted. Version: iOS 11, Beta 4 Notes: Configuration: Tested so far on an iPad Air 2 and an iPhone 6s Plus running iOS 11 beta.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!