-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to how validation displays in UI #4354
Conversation
@Beamanator I made a few changes to the original proposal to make it easier for us to apply the enhancements of #2936.
I think this is better than the original proposal because:
|
I marked this as ready for review to get a bit of help 😅 This is working fine on Web/Desktop, but on mobile the The Weird that this only happens on Mobile. Do you have any idea why this might be happening? ios.mp4Just a note that this problem also happens if I try the original proposal. |
src/libs/OptionsListUtils.js
Outdated
* Helper method that returns the text to be used for the header's message and title (if any) | ||
* | ||
* Helper method that returns the text to be used for the header's message and title (if any), the isValid | ||
* property decides if we should show the search results for the given search value. | ||
* @param {Boolean} hasSelectableOptions | ||
* @param {Boolean} hasUserToInvite | ||
* @param {String} searchValue | ||
* @param {Boolean} [maxParticipantsReached] | ||
* @return {String} | ||
* @return {Object} | ||
*/ | ||
function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, maxParticipantsReached = false) { | ||
if (maxParticipantsReached) { | ||
return translate(preferredLocale, 'messages.maxParticipantsReached'); | ||
return {message: translate(preferredLocale, 'messages.maxParticipantsReached'), isValid: true}; | ||
} | ||
|
||
if (!hasSelectableOptions && !hasUserToInvite) { | ||
if (/^\d+$/.test(searchValue)) { | ||
return translate(preferredLocale, 'messages.noPhoneNumber'); | ||
} | ||
if (isSearchingInvalidPhone(searchValue)) { | ||
return {message: translate(preferredLocale, 'messages.noPhoneNumber'), isValid: false}; | ||
} | ||
|
||
return searchValue; | ||
if (!hasSelectableOptions && !hasUserToInvite) { | ||
return {message: searchValue, isValid: true}; | ||
} | ||
|
||
return ''; | ||
return {message: '', isValid: true}; |
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.
We should probably decouple the header message
from the rendering of the SectionList
. If needed, we can just add another prop that is along the lines of shouldShowSectionList
src/libs/OptionsListUtils.js
Outdated
function isSearchingInvalidPhone(searchValue) { | ||
return searchValue && CONST.REGEX.DIGITS_AND_PLUS.test(searchValue) && !Str.isValidPhone(searchValue); | ||
} |
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.
Doesn't seem like we need a whole method for this and can just use it below
src/components/OptionsList.js
Outdated
// eslint-disable-next-line react/forbid-prop-types | ||
headerMessage: PropTypes.object, |
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.
Mentioned above I don't think we want to couple the headerMessage and rendering the SectionList but if so, you should shape the expected object instead of disabling the lint
@rdjuric Hmm I tried reproducing the error you saw on iOS and I wasn't getting any weird behavior like you 😅 Did you check the debugger logs? (Flipper or remote debugging with Chrome?) |
@Beamanator Yes, checked it and both Flipper and Chrome debugging shows nothing weird. They even show the Just to confirm the steps, using the last commit from this branch:
Did this happen in your tests @thienlnam? |
I run into the same thing, but isn't that just because you don't have any contacts with that number so there are no results? |
I think the main point of this specific issue is to make sure the "i couldn't validate the phone number" error doesn't just get displayed in the console for nobody to see. So either:
What do y'all think? |
@thienlnam If the number isn't in the contacts but is valid, we add them as a
This looks like a must-do as our regex lets numbers like +55 (just a country code) pass as valid. But I think this was an improvement to be made in #2936?
Hmm. I understand the point but I think that this is worst UX than not showing the result at all. |
Took me a while but I realized that we already filter results for invalid numbers here (see code), so conditionally rendering the App/src/libs/OptionsListUtils.js Lines 466 to 472 in d15beee
I think all that is left is making sure that
by doing the equivalent test in our Here's a vid comparing the behavior on this PR and on Staging. I think this is what we're looking for in this issue? PRxStaging.mov |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Hmm I do like your changes @rdjuric but I was also hoping we could avoid having this situation happen (sorry if it wasn't clear in the issue): Screen.Recording.2021-08-05.at.10.59.23.AM.mov |
A.k.a. if a user clicks the "new chat" but the phone number isn't 100% valid (a.k.a. our API returns an error) it would be best to show this error to the end user instead of just silently throw the console error and a normal user won't know what happened |
Ahh, I see @Beamanator! Thanks for the video. Do we want to show a |
NP! Ooh I think a |
🚀 Deployed to staging in version: 1.0.82-8🚀
|
🚀 Deployed to production by @francoisl in version: 1.0.83-1 🚀
|
Details
Fixed Issues
$ #2934
Tests
QA Steps
Tested On
Screenshots
Web
web.mov
Mobile Web
mWeb.mp4
Desktop
desktop.mov
iOS
iOS.mp4
Android
Android.mp4