-
Notifications
You must be signed in to change notification settings - Fork 11
Fix Site Address UI Bugs When Displaying In-Page Errors #596
Conversation
This is causing an issue where when there's an XML-RPC error displayed, the text field will no longer be disabled when the user tries to submit another site URL. This was first created in cf6b66f. As far as I can understand, there doesn't seem to be a critical need to keep this. The reference will still be pointed to the _current text field_ if the cell is recreated.
When an XML-RPC error is displayed, the URL that the user entered gets cleared. This retains the text to match with our other error handling UIs like the fancy dialog which does not clear the text field.
This function should be used instead of the one with the `animating: loading` argument to avoid incorrectly disabling the loading state of the button.
6f2f13d to
52dfad9
Compare
This fixes this bug: 1. Log in with a site address that has a blocked XML-RPC. For example, https://do.wpmt.co/ddos. 2. After the error is displayed, log in with a valid self-hosted site address. 3. Continue entering the credentials to log in. 4. You will not be able to. This also does not work with WooCommerce. The WC app will spit out a "...is connected to a different account" error.
| } | ||
|
|
||
| if row == .siteAddress { | ||
| siteURLField = nil |
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 removed this because this was preventing the text field from being disabled when the user tapped Continue for the second time. There are no implications in removing this, right? 😅
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 doesn't appear to be a side effect. It looks like this was there to clean up setting the siteURLField as first responder, but your change seems to have made no difference. Sooooo 👍 .
The idea is to enable/disable the I checked internal, and it's doing the same thing, so this definitely pre-dates your PR. But that's why that callback is there. |
|
I know this isn't your doing (it appears to be mine 🤦 ), but there is a |
ScoutHarris
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!
![]()
Ah, thanks for the explanation!
Since you asked nicely... removed in d6447e7. 🤣 Thank you very much for the review, @ScoutHarris! |
Part of fixing woocommerce/woocommerce-ios#4034.
There is a linked WP PR for this: wordpress-mobile/WordPress-iOS#16655.
Originally intended to fix just WooCommerce but apparently, WP has the same issue. So this fixes both apps. 🤸
Findings
Both apps have this problem when logging in with a site address. This is for WordPress specifically:
WordPressOrgXMLRPCValidator.guessXMLRPCURLForSitefails because we did not provide the scheme.This problem only surfaces when the user made a mistake on the first try. Which is quite likely. It also happens if there was previously an XML-RPC error. Or any other error that is displayed below the site address text field.
Here is a video showing this bug:
wp-before.mov
If there was no error on the first try, the app is able to log the user in because we automatically fix the
siteAddress.You'll also notice in the video that the text disappears when the error is displayed. And the Continue button also does not show the activity indicator anymore if the user tries a second time. It looks like the app is doing nothing.
Solution
Logging In
For some reason, if the error is displayed at some point, the
loginFields.siteAddressgets reset because this callback gets called:WordPressAuthenticator-iOS/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift
Lines 312 to 315 in 45d02a7
I still have no idea why that text field change callback is called. But I fixed it by resetting
loginFields.siteAddressbefore any view controller is displayed. See here for the fix. Let me know if there's a better way for this.Disappearing Text
I fixed the disappearing text by resetting the value when the cell is recreated in
configureTextField:WordPressAuthenticator-iOS/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift
Line 311 in aa020aa
Activity Indicator
The reason the activity indicator on the button does not show up when the user retries because this block gets called right after the activity indicator is shown:
WordPressAuthenticator-iOS/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift
Line 309 in 26e7de7
So the activity indicator gets dismissed immediately.
I fixed this by keeping the “view is loading” state in a variable:
WordPressAuthenticator-iOS/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift
Lines 22 to 29 in aa020aa
And making sure that the
configureSubmitButtonuses that state so the activity indicator is not unintentionally dismissed:WordPressAuthenticator-iOS/WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift
Lines 94 to 98 in aa020aa
Let me know if there's a better way to do this. I wasn't quite sure how to properly handle this. I wanted to use a
didSethandler but it looks likeconfigureViewLoadingis an override from the parent class. So I couldn't just remove it.Here is the final result:
wp-after.mov
Testing