UIReturnKeySearch sends newline character, breaks API flow

Originator:joshavant
Number:rdar://14484206 Date Originated:18-Jul-2013 03:37 PM
Status:Closed Resolved:
Product:iPhone OS Product Version:7.0
Classification:Other Bug Reproducible:Always
 
18-Jul-2013 03:37 PM Josh Avant:
Summary:
When a UIReturnKeySearch is clicked, a newline character is sent to`searchBar:shouldChangeTextInRange:replacementText:` (when using UISearchBar, for example).

This is a poor design because the key is presented to the user as a blue, action-type key labelled 'Search', which doesn't suggest that it would be used to insert a newline into the text field.

Further, if NO is returned from `searchBar:shouldChangeTextInRange:replacementText:` when the UIReturnKeySearch button is clicked, `searchBarSearchButtonClicked:` will not be called by the framework.

This forces the developer to accept the newline character in `searchBar:shouldChangeTextInRange:replacementText:`, then sanitize the UISearchBar's text in `searchBarSearchButtonClicked` for this specific scenario, which is a bad design.

Steps to Reproduce:
1. Run the attached code
2. Touch the UISearchBar text field to activate the keyboard
3. Press Search key

Expected Results:
-No newline character is sent to `searchBar:shouldChangeTextInRange:replacementText:`.
-`searchBarSearchButtonClicked:` is called, independent of the return result for `searchBar:shouldChangeTextInRange:replacementText:`.

Actual Results:
`searchBar:shouldChangeTextInRange:replacementText:` returns NO, causing `searchBarSearchButtonClicked:` not to be called.

18-Jul-2013 03:37 PM Josh Avant:
'UIReturnKeySearchNewline.zip' was successfully uploaded

Comments

Closed

I closed this issue, since it fell out-of-date.


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!