From 080304ae2d4074f99134ba095958c6c188c1922e Mon Sep 17 00:00:00 2001 From: Dan Jackson Date: Tue, 19 Dec 2017 14:56:23 -0800 Subject: [PATCH] Trim whitespace from STPAddressFieldTableViewCell contents when reading the property. Fixes a user-interaction issue (knowingly) introduced by #870. When selecting email or zip code autocompletion suggestions, they fail validation. US zip codes would fail immediately, while email addresses waited until the field lost focus. This was an unpleasant UX experience. This is both a very concise fix, but also one I like. It keeps the contents of the text field unchanged, and does not interfere with editing in any way. Leading & trailing spaces are simply ignored while validating, and they are likewise ignored when considering what the logical contents of the cell/text field are. This results in the trimmed string being persisted to the server, and the trimmed string being passed around the payment context (like copying to the other address type) --- Stripe/STPAddressFieldTableViewCell.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Stripe/STPAddressFieldTableViewCell.m b/Stripe/STPAddressFieldTableViewCell.m index 1d6cbbb8f68..c853bb57ad4 100644 --- a/Stripe/STPAddressFieldTableViewCell.m +++ b/Stripe/STPAddressFieldTableViewCell.m @@ -27,6 +27,8 @@ @interface STPAddressFieldTableViewCell()