Repository navigation
Conversation
- The Web Address dialog enabled OK only for text matching Patterns.WEB_URL, so an empty field kept OK disabled and the value could not be cleared once set - Add validateOptionalUrl(), which accepts an empty value or a valid URL, and use it for the URL validation type (only used by Web Address) - The save path already sends an empty user_URL, matching Calypso and Jetpack iOS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Once the Web Address in Jetpack Android's Account Settings was set, it couldn't be cleared: the OK button was disabled whenever the field was empty. Calypso and Jetpack iOS already allow clearing it. This PR lets an empty Web Address be saved.
Attempts to fix CMM-2487.
Description
Cause:
EditTextPreferenceWithValidationenables the dialog's OK button on each keystroke only when the text matchesPatterns.WEB_URL(ValidationType.URL). An empty string never matches, so once the field is cleared OK stays disabled, and Cancel restores the saved value.Change:
validateOptionalUrl()toValidationUtils.kt. It accepts an empty value or a valid URL, the same ruleUnifiedCommentsEditViewModelalready applies to the comment author's web address.ValidationType.URL. Web Address in Account Settings is the only preference that uses this validation type, so no other screen is affected.Nothing else needed to change:
AccountSettingsViewModel→PushAccountSettingsUseCasealready sends the value through asuser_URL, and FluxC updateswebAddressfrom the response, so an empty value is pushed and shown as blank.Testing instructions
Clear the Web Address:
https://example.com), tap OK, and wait for it to saveValidation still works:
not a urlVerified:
ValidationUtilsTestpasses, including a new test for the empty value, and that test fails with the empty-value check removed.Screenshot of the "OK" button still active when the web address field is blank:
