[HOLD #2934] Enhancements for "Debounce account search typing & fix how validation displays in UI"
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
On hold for #2934 since that one adds a necessary fix to phone number validation, and this one builds on that
These are enhancements are related to https://github.com/Expensify/Expensify.cash/issues/2934. Please review that job for more details Whomever is assigned that issue can work on these concurrently or after 2934 is fixed. If the assigner of 2934 doesn't want to work on this issue then it's held for anyone else until a week after 2934 is closed (to ensure there aren't regressions)
Enhancements:
When entering an email address or phone number in OptionsSelector's TextInputWithFocuStyles (on all screens where this exists), the app should do a few things:
- Show a spinner when user is typing (debounce input, so stop showing spinner 300ms after user stops typing and do validation checks below)
- When user has stopped typing for 300ms, do basic front-end validation checks
- Email validation looks decent for now (
Str.isValidEmaiand!Str.isDomainEmail) - Phone number validation should get more strict, it's super basic at the moment (see
Str.isValidPhone)
- Email validation looks decent for now (
- If above validation passes, do API-level validation for phone numbers only
- Call the new Expensify API command
IsValidPhoneNumber, which validates phone numbers in this format:'(\+?\d{10,15}|\d\d\d-\d\d\d-\d\d\d\d)'.
- Call the new Expensify API command
Make sure validation error messages still show correctly
- If phone number is invalid, show error message
"Please enter a phone number including the country code e.g +447814266907". Example: -
- If email address is invalid, show
"Please enter a valid email address". Examples: -
Triggered auto assignment to @mateocole (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.
Triggered auto assignment to @thienlnam (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Removing @thienlnam b/c I'm happy to review proposals π
Oops, shouldn't have added Exported yet since this job isn't on Upwork yet :O
Proposal π
When entering an email address or phone number in OptionsSelector's TextInputWithFocuStyles (on all screens where this exists), the app should do a few things:
- Show a spinner when user is typing (debounce input, so stop showing spinner 300ms after user stops typing and do validation checks below)
- When user has stopped typing for 300ms, do basic front-end validation checks Email validation looks decent for now (Str.isValidEmai and !Str.isDomainEmail) Phone number validation should get more strict, it's super basic at the moment (see Str.isValidPhone)
- If above validation passes, do API-level validation for phone numbers only Call the new Expensify API command IsValidPhoneNumber, which validates phone numbers in this format:
(\+?\d{10,15}|\d\d\d-\d\d\d-\d\d\d\d). Show errors below input box If phone number is invalid, show error message "Please enter a phone number including the country code e.g +447814266907". - If email address is invalid, show "Please enter a valid email address". Examples:
Research/Investigation π΅π»ββοΈ
- We need to implement debouncing
- Need to show the spinner
- Handle Validations
Approach π¨πΌβπ»
File of concern : Multiple (UI + Logic/Services)
- For implementing debouncing we can use
lodash. - We need to call the validate method/API on every keypress (debounced)
- The validation API and other required things are already provided by the author ππΌ
- Sibling issue #2934 talks about the implementation of error methods, therefore some amount of dependency exists on the resolutions of the following issue.
Best Practices ππΌ
- No hard-coded regexes
- No inline styling
- Accessibility
- Follow React Native best practices
Testing Strategy π§ͺ
- Unit tests for the underlying modules
Expected Delivery Time π¦
Approx 3-7 days. Considering any possible blockers
Open Questions β
- [ ] Any documentation for
IsValidPhoneNumber. So far this is not been implemented in the codebase. - [ ] Any UI design for this?
- [ ] Any specific spinner component (
<ActivityIndicator />)?
Previous Experience π πΌββοΈ
- https://github.com/Expensify/Expensify.cash/issues/2811
Thanks for the proposal, @pranshuchittora !
Here's some responses to your questions:
-
Any documentation for
IsValidPhoneNumber. So far this is not been implemented in the codebase.- Input: Object in format:
{ phoneNumber: "720-111-1111"}.- Valid if
phoneNumbersatisfies this regex:'(\+?\d{10,15}|\d\d\d-\d\d\d-\d\d\d\d)' - Example:
API.IsValidPhoneNumber({ // you will have to create this in `/src/libs/API.js` phoneNumber: "720-111-1111", }).then((response) => { ...
- Valid if
- Output: Json with these properties:
isValid(boolean) - is the passed phone number validjsonCode(number) - should be200if the request made it to the api & back to front-end successfully. Otherwise, maybe an internet connection error occurredrequestID(string) - this is for internal expensify log tracking, not needed for this job
- Input: Object in format:
-
Any UI design for this?
- For error message designs, please follow what you see in the screenshots in the original post.
- For spinner design, see below
-
Any specific spinner component (
)? ActivityIndicatorshould be perfect, we currently use that component in a few places in our app- @shawnborton I bet we can just do
size="small"on this spinner, right? Care what color we use? MaybethemeColors.spinner?
Is that works @Beamanator
https://user-images.githubusercontent.com/32242596/118526334-c0d5a300-b75d-11eb-8f8a-f78ab2c8de60.mp4
Debounce
https://user-images.githubusercontent.com/32242596/118526327-bf0bdf80-b75d-11eb-9434-3d660618fa94.mp4
Hey @pranshuchittora !
I like the debouncing, but I believe we should show the spinner while we're waiting for the user to stop typing (for 300ms) and while waiting or the IsValidPhoneNumber response to come back. Also are you planning to make sure the "Concierge" & "pranshu_...@srmuniv..." chats are hidden while the text input is debounced?
Hi @Beamanator
- Will add the spinner
Also are you planning to make sure the "Concierge" & "pranshu_...@srmuniv..." chats are hidden while the text input is denounced?
Not sure about this but I have decided to keep them because so that user have something to go for. Thinking in terms of the User Experience, it is better to show something instead of nothing. Would love to hear your thoughts on this as well :)
βοΈ Spinner βοΈ Debounce βοΈ Ignore phone number validation on email βοΈ Edge cases
https://user-images.githubusercontent.com/32242596/118657125-d18f2300-b808-11eb-84d1-b4f614161168.mp4
cc @Beamanator
I absolutely don't consider myself an expert in design, which is why I'd recommend we consult with the @Expensify/design group :D
Hey designers! How do y'all feel about the above design, specifically:
- When typing in that text box, should we show only the spinner? Or should we also show matching chats?
- When the user stops typing and there's some validation error (phone or email) and then keeps typing, the error should go away right?
When typing in that text box, should we show only the spinner? Or should we also show matching chats?
I think we should show matching chats. I know there have been times where I partially know a phone/name/email and search results fill in the rest, so I think it's helpful.
When the user stops typing and there's some validation error (phone or email) and then keeps typing, the error should go away right?
This makes sense to me, yeah.
I think the constant jumping around feels really strange. Could we do something where:
- There is always a small gap under the search box and above the top search result row. When there is the small validation message below the search box, it fills this space without causing the rows below it to jump around
- Could we place the loader in the text input, perhaps floating off to the right or something? Or perhaps place it absolutely positioned on top of the search results, and perhaps slightly fade out the results while typing?
Basically this flow should feel ultra smooth and not bouncey/jumpy like it does in the video, so hopefully the ideas above will help us solve that.
Ooh I like these ideas! What do you think @pranshuchittora ?
Ooh I like these ideas! What do you think @pranshuchittora ?
I agree with all the points. @Beamanator can put a comment consolidating all the new design requirements so that itβs properly documented.
Here's the updated design requirements:
- While typing:
- Always show list of matching chats (as you have in your video)
- Show spinner (either in the text input floating off to the right, or on top of search results (probably centered vertically & horizontally) with search results slightly grayed out but still readable)
- Clear error message (if one existed)
- When done typing, error message appears below the search box - there should always be space here, even when error doesn't exist - this should prevent components from jumping around
Main important thing to keep in mind:
Basically this flow should feel ultra smooth and not bouncey/jumpy
Created the job in Upwork, made it private and invited @pranshuchittora , once you accept we'll assign this issue to you https://www.upwork.com/jobs/~014262863179787232
Hired @pranshuchittora in Upwork, assigning this issue now, @Beamanator will be reviewing the PR
Thoughts @Beamanator @shawnborton @michaelhaxhiu @michelle-thompson
https://user-images.githubusercontent.com/32242596/118997482-51062900-b9a6-11eb-81cd-4142fe2d5e99.mp4
As per this ππΌ
Here's the updated design requirements:
While typing:
- Always show list of matching chats (as you have in your video)
- Show spinner (either in the text input floating off to the right, or on top of search results (probably centered vertically & horizontally) with search results slightly grayed out but still readable)
- Clear error message (if one existed)
When done typing, error message appears below the search box - there should always be space here, even when error doesn't exist - this should prevent components from jumping around
Main important thing to keep in mind:
Basically this flow should feel ultra smooth and not bouncey/jumpy
Looking great!!
One quick comment: When an invalid email address is shown, can you show the message "Please enter a valid email address" below the text field?
