You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PAID] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page #17770
Notice that the leading spaces aren’t removed while displaying email/phone number
Expected Result:
Leading or trailing spaces should be removed and email.phone number should be displayed accordingly for better UI
Actual Result :
Leading spaces makes improper indentation while display.
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
MacOS / Chrome / Safari
MacOS / Desktop
Version Number: 1.3.3 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation
Please re-state the problem that we are trying to solve in this issue.
Leading whitespaces aren’t truncated while saving email/phone number in new contact method page
What is the root cause of that problem?
We are adding trim only while validating the submit button rather than validating for submit button we should validate at time of text change only so this will make sure to remove all white space before storing/displaying actualy value
What changes do you think we should make in order to solve the problem?
On NewContactMethodPage.js -> we need to trim value at onLoginChange() and remove trim from validateForm() since we are limiting the white space at first place so need to to extra trim for submit button
So User.addNewContactMethodAndNavigate() method will save login value with leading and trailing space. This is the root cause of the problem.
What changes do you think we should make in order to solve the problem?
To solve this we can think to trim login while save to state at line 69 within onLoginChange().
But it is not advisable because user may enter Email Or Phone number within login field. So if user typing email then trim() during save to state will be ok, because generally blank space not comes within email so user will not try to enter blank space within email.
But if user enter Phone number then user have habit to enter phone number like "123 4567 8901" i.e. with space. So if we trim value during onChange, then as soon as user type space within phone number onLoginChange() will trim space during save to state. So it will make bad user experience and user will not able to enter space within phone number.
So better approach is to trim login within submitForm() function and use trimmed login value for lodashGet() and addNewContactMethodAndNavigate() api. So modified submitForm() function code looks as shown below.
submitForm(){// Trim leading and trailing space from loginconstlogin=this.state.login.trim();// If this login already exists, just go back.if(lodashGet(this.props.loginList,login)){Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS);return;}User.addNewContactMethodAndNavigate(login,this.state.password);}
So this will solve the issue i.e. truncate leading/trailing white space from email or phone number, and allows to enter space within phone number. Result video attached below.
What alternative solutions did you explore? (Optional)
None.
Results
Truncate leading/trailing space from email.
Email.mov
Truncate leading/trailing space from Phone and allow space in between phone number.
Looks like something related to react-navigation may have been mentioned in this issue discussion.
As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.
changed the title [-]Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/-][+][$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/+]on Apr 22, 2023
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@Santhosh-Sellavel] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: Not need I guess.
[@Santhosh-Sellavel] Determine if we should create a regression test for this bug.
changed the title [-][HOLD for payment 2023-05-03] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/-][+][PAID] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/+]on May 8, 2023
Activity
MelvinBot commentedon Apr 21, 2023
Triggered auto assignment to @strepanier03 (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.MelvinBot commentedon Apr 21, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)dhairyasenjaliya commentedon Apr 21, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
NewContactMethodPage.js-> we need to trim value atonLoginChange()and remove trim fromvalidateForm()since we are limiting the white space at first place so need to to extra trim for submit buttonChanges
onLoginChange(login) { + const validate = login.trim(); this.setState({login:validate}); } /** * Determine whether the form is valid * * @returns {Boolean} */ validateForm() { - const login = this.state.login.trim(); + const login = this.state.login const phoneLogin = LoginUtils.getPhoneNumberWithoutSpecialChars(login); return (Permissions.canUsePasswordlessLogins(this.props.betas) || this.state.password) && (Str.isValidEmail(login) || Str.isValidPhone(phoneLogin)); }What alternative solutions did you explore? (Optional)
PrashantMangukiya commentedon Apr 21, 2023
Proposal
Posting proposal early as per new guidelines
Please re-state the problem that we are trying to solve in this issue.
Leading whitespaces aren not truncated while saving email/phone number in new contact method page.
What is the root cause of that problem?
We can see within
onLoginChange()we do not trimloginbefore save to state, so login value will be with leading and trailing space if entered.App/src/pages/settings/Profile/Contacts/NewContactMethodPage.js
Lines 68 to 70 in 4f7cfdb
Also during
submitForm()we do not trimthis.state.loginas shown below,App/src/pages/settings/Profile/Contacts/NewContactMethodPage.js
Lines 85 to 92 in 4f7cfdb
So
User.addNewContactMethodAndNavigate()method will saveloginvalue with leading and trailing space. This is the root cause of the problem.What changes do you think we should make in order to solve the problem?
To solve this we can think to trim login while save to state at line 69 within
onLoginChange().But it is not advisable because user may enter Email Or Phone number within login field. So if user typing email then trim() during save to state will be ok, because generally blank space not comes within email so user will not try to enter blank space within email.
But if user enter Phone number then user have habit to enter phone number like "123 4567 8901" i.e. with space. So if we trim value during onChange, then as soon as user type space within phone number onLoginChange() will trim space during save to state. So it will make bad user experience and user will not able to enter space within phone number.
So better approach is to trim login within
submitForm()function and use trimmed login value forlodashGet()andaddNewContactMethodAndNavigate()api. So modifiedsubmitForm()function code looks as shown below.So this will solve the issue i.e. truncate leading/trailing white space from email or phone number, and allows to enter space within phone number. Result video attached below.
What alternative solutions did you explore? (Optional)
None.
Results
Truncate leading/trailing space from email.
Email.mov
Truncate leading/trailing space from Phone and allow space in between phone number.
Phone.mov
Phone2.mov
MelvinBot commentedon Apr 21, 2023
Looks like something related to
react-navigationmay have been mentioned in this issue discussion.As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our
DeprecatedCustomActions.jsfiles should not be accepted.Feel free to drop a note in #expensify-open-source with any questions.
strepanier03 commentedon Apr 22, 2023
Able to recreate following instructions but oddly I have the email listed twice, once with the extra spaced and once without.
[-]Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/-][+][$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/+]MelvinBot commentedon Apr 22, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01b41c774d839dccd0
MelvinBot commentedon Apr 22, 2023
Current assignee @strepanier03 is eligible for the External assigner, not assigning anyone new.
MelvinBot commentedon Apr 22, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (
External)18 remaining items
strepanier03 commentedon May 4, 2023
Just getting back from out of office and working to catch up on this now. I'll have an update shortly.
strepanier03 commentedon May 4, 2023
@ashimsharma10 - I have hired you to a bug report job in Upwork.
@Santhosh-Sellavel and @PrashantMangukiya - I have hired you to the Upwork job as well.
@Santhosh-Sellavel - If you can finish the BZ checklist I'll update the comment and make any necessary reg test GHs.
I'll check in later today to pay what I can.
PrashantMangukiya commentedon May 4, 2023
@strepanier03 Offer accepted on Upwork.
strepanier03 commentedon May 4, 2023
@PrashantMangukiya and @ashimsharma10, I have paid you both via Upwork and closed contracts, thank you both!
PrashantMangukiya commentedon May 4, 2023
@strepanier03 Received, Thank you.
Santhosh-Sellavel commentedon May 5, 2023
cc: @luacmartins let me know if differ on anything, thanks!
Santhosh-Sellavel commentedon May 7, 2023
Regression steps
From the PR itself looks good to me
👍 or 👎
cc: @luacmartins or @strepanier03
Santhosh-Sellavel commentedon May 7, 2023
@strepanier03 Accepted offer thanks!
strepanier03 commentedon May 8, 2023
REg test added and payment finalized. Going to close this now.
Thank you everyone!
[-][HOLD for payment 2023-05-03] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/-][+][PAID] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page[/+]