Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 1.3.85.0
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
Expensify/Expensify Issue URL:
Issue reported by: @daveSeife
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697554340620449
Action Performed:
- Click on 'Profile avatar'
- Click on 'Profile' link
- Click on 'Display name'
- Click on 'First name' and write 'Expensify'
- Click on 'Last name' and enter some value
- Click on 'fix the errors' link above save button
Expected Result:
No console log error when clicking on 'fix the errors ' link
Actual Result:
Console log error when clicking on 'fix the errors ' link
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- Android: Native
- Android: mWeb Chrome
- iOS: Native
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- MacOS: Desktop
Screenshots/Videos
Android: Native
Screen.Recording.2023-10-17.at.6.53.27.PM.mov
Android: mWeb Chrome
iOS: Native
Screen.Recording.2023-10-17.at.6.26.59.PM.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2023-10-17.at.6.33.33.PM.mov
MacOS: Desktop
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01d7ec16953ac2e5af
- Upwork Job ID: 1714639879485181952
- Last Price Increase: 2023-10-25
Activity
melvin-bot commentedon Oct 18, 2023
Triggered auto assignment to @NicMendonca (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.[-]Display Name - Console log error when clicking on 'fix the errors ' link[/-][+][$500] Display Name - Console log error when clicking on 'fix the errors ' link[/+]melvin-bot commentedon Oct 18, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01d7ec16953ac2e5af
melvin-bot commentedon Oct 18, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Oct 18, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (
External)rayane-d commentedon Oct 18, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
There is a console error when clicking on the "Fix the errors" link in the Display Name page after entering an invalid value for the First Name or Last Name field.
What is the root cause of that problem?
the DisplayNamePage component code lacks proper references to the input elements, preventing us from programmatically focusing on the input fields when clicking on the "Fix the errors" link. This results in a null reference error when attempting to access focusInput properties / methods here.
Recording.2023-10-18.111137.mp4
What changes do you think we should make in order to solve the problem?
in the DisplayNamePage component :
Create two refs, firstNameInputRef and lastNameInputRef, to reference the "First Name" and "Last Name" input elements, respectively.
pass these refs to the respective InputWrapper components using the ref prop.
Result:
Recording.2023-10-18.111015.mp4
What alternative solutions did you explore? (Optional)
abdel-h66 commentedon Oct 18, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Display name page form does not focus inputs with error upon
Please fix the errors in the form before continuing.What is the root cause of that problem?
On the forms that use
FormProvider, clicking onPlease fix the errors in the form before continuing.will actually trigger a silent errorUncaught TypeError: Cannot read properties of null (reading 'isFocused')The issue happens during the registration in here
inputRefs[inputID] = newRef;without setting the value inside .current it will cause them to vanish on re-render to become an empty object like thisfocus-input.mp4
What changes do you think we should make in order to solve the problem?
inputRefs.current = {[inputID] : newRef, ...(inputRefs.current || {})};const focusKey = _.find(_.keys(inputRefs.current), (key) => _.keys(errorFields).includes(key));This solution will fix the issue for all the other components that are using
FormProviderfor form managementWhat alternative solutions did you explore? (Optional)
The other option would be to simply use the
Forminstead ofFormProvidercomponent similar to other forms where thePlease fix the errors in the form before continuing.does not have this issue.FormProviderand simply retire it.N/A
shubham1206agra commentedon Oct 18, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Display Name - Console log error when clicking on 'fix the errors' link
What is the root cause of that problem?
On the forms that use
FormProvider, clicking onfix the errorswill actually trigger a console errorUncaught TypeError: Cannot read properties of null (reading 'isFocused')The is due to multiple reasons:
registerInputhas bugs due to incorrectly using refs, which are causing bugsInputWrappergets re-rendered due to change inFormContext, asregisterInputhas a dependency ofinputValues, anderrors. This is creating a new ref on every input change sincepropsToParse.refis null in this case.What changes do you think we should make in order to solve the problem?
We need to fix both problems
App/src/components/Form/FormProvider.js
Line 103 in 935e891
useRef({})to initialize it with{}App/src/components/Form/FormProvider.js
Line 208 in 935e891
inputRefs.current[inputID] = newRef;to correctly use refsApp/src/components/Form/FormProvider.js
Line 311 in 935e891
inputRefs={inputRefs.current}to correctly pass inputRefs toFormWrapperInputWrapperin case of forwardRef to be null (using the memo also), and pass it in arguments instead of doing it insideregisterInput, and pass it in arguments instead. In InApp/src/components/Form/InputWrapper.js
Line 19 in 935e891
const ref = useMemo(() => forwardedRef || createRef(), [forwardedRef]);and pass it inApp/src/components/Form/InputWrapper.js
Line 21 in 935e891
What alternative solutions did you explore? (Optional)
N/A
DylanDylann commentedon Oct 19, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Clicking 'Fix The Errors" does not focus on the fields
What is the root cause of that problem?
Currently we don't pass ref input as prop in DisplayNamePage
In
App/src/components/Form/FormProvider.js
Line 207 in 19ef1ca
propsToParse.refwill be null, it'll runcreateRef()in here and get errorWhat changes do you think we should make in order to solve the problem?
In DisplayNamePage we should add ref as prop in two inputs
firstNameandlastNameWhat alternative solutions did you explore? (Optional)
Result
Screen.Recording.2023-10-18.at.11.33.37.mov
dukenv0307 commentedon Oct 19, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Display Name - Console log error when clicking on 'fix the errors ' link
What is the root cause of that problem?
We always assign a new ref for
inputRefs[inputID]wheneverregisterInputwithout checkinginputRefs[inputID]is null or not. Then when we change the text input, a new refcreateRef()is assigned forinputRefs[inputID]and then it is null.App/src/components/Form/FormProvider.js
Lines 207 to 208 in 229cb5d
What changes do you think we should make in order to solve the problem?
We should check if the inputRef is already not empty we will not assign a new ref for it
And here we will use
inputRefs[inputID]instead ofnewRefApp/src/components/Form/FormProvider.js
Line 232 in 229cb5d
What alternative solutions did you explore? (Optional)
NA
Result
Screencast.from.19-10-2023.16.03.17.webm
melvin-bot commentedon Oct 24, 2023
@ntdiary, @NicMendonca Eep! 4 days overdue now. Issues have feelings too...
ntdiary commentedon Oct 24, 2023
Will review later.
ntdiary commentedon Oct 25, 2023
@kbecciv, @NicMendonca, not reproducible, it was fixed in PR #29962.
melvin-bot commentedon Oct 25, 2023
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸