App: [$1000] Dev - Pressing on ‘fix the errors’ on validation forms throw error message
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
- Log in any account
- Navigate to Settings > Any workspace > Connect bank account > Connect Manually > Press Save&Continue without any data
- Will show please “fix the errors” press on ‘fix the error’ > Notice in console it show error’s
Expected Result:
Pressing “fix the error” should not show any console error/warning
Actual Result:
Pressing “fix the error” shows console error/warning ’Uncaught TypeError: Cannot read properties of undefined (reading ‘left’) ’ on web and on native platforms it shows ’ref.measureLayout must be called with a node handle or a ref to a native component`
Workaround:
unknown
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: v1.2.45-0
Reproducible in staging?: Y (tested in web)
Reproducible in production?: y (tested in web)
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:

**Expensify/Expensify Issue URL:**
**Issue reported by:** @dhairyasenjaliya
**Slack conversation:** https://expensify.slack.com/archives/C049HHMV9SM/p1672390562408519
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~0147ce5eb30fa3ad88
- Upwork Job ID: 1609834450585026560
- Last Price Increase: 2023-01-02
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 52 (37 by maintainers)
@aldo-expensify, actually it is a regression from https://github.com/Expensify/App/pull/13514
Issue
this.formdoes not refer to the actual relative node, which is the underlyingScrollViewProposal
pass down / forward the
refproperly toScrollViewWithContextcomponentThis gives us the flexibility to either consume it using a
ScrollContext.Consumeror directly pass arefto theScrollViewWithContextcomponent.update
To address issue pointed out by @dhairyasenjaliya (https://github.com/Expensify/App/issues/13909#issuecomment-1368838061) which is caused by this prop passed into ScrollView:
scrollToOverflowEnabledwhich would happen anyway (iOS only) fixing the issue in question here.To fix it i propose that we need to add another prop and set its default to be
true:And on the
Form.jsBecause as far as I looked,
scrollToOverflowEnabledhas been set to true by default in this PR (https://github.com/Expensify/App/pull/13514) to fix an issue withWorkspacePageWithSectionscomponent. @chrispader correct me if I’m wrong. (I’m new in here 😉) So it is safe to setscrollToOverflowEnabledtofalsefor theFormcomponent which in turn I believe will not need any regression testing.@bfitzexpensify, the C+ compensation is pending here Also I think the reporting compensation for @dhairyasenjaliya is due.
Can you try your solution on a long form at ios? e.g. AddDebitCardPage, when opening picker it will throw an error
https://user-images.githubusercontent.com/83179295/210420283-9ebb415b-84e7-4d69-82fb-f8dde589cfe6.mov
I have added some top margin because the picker needs to be near the bottom.
@dhairyasenjaliya I’m not sure if this regression was ever fixed correctly. Even on native,
As such, the
this.formpoints torefof the class component. When supplying it tomeasureLayout, we’re getting this error:this.form.scrollTois undefined on native as well. Would be better to remove this functionality entirely since this is not available on any platform.Proposal
We already wrap the view with ScrollViewWithContext, but we didn’t consume the provided value. So, what we need to do is to wrap it again with the consumer to receive the scroll view ref.
Proposal
The error occurs due to
this.form.scrollTobeing undefined. However, we need to investigate why this is undefined. None of the above proposals try to find and ultimately fix this.Issue
this.formreturns reference to the classScrollViewWithContextinstead of theScrollViewcomponent itself. As seen here: https://github.com/Expensify/App/blob/main/src/components/ScrollViewWithContext.js#L41-L42Thus we need to use
scrollViewRefproperty of the class componentScrollViewWithContext.Fix
We need to change the following:
Proposal
Here for the web we are not getting
this.form.scrollToindex due to that we are receiving an undefined warning we need to add more validation to check ifform.scrollTohas a valid scroll index based on that we are moving screen with the keyboard openIMO we need to use
_.isFunctionto check & validform.scrollTothis is already being used in many placesAlso need to change
typeof focusInput.measureLayout === 'function'to ->_.isFunction(focusInput.measureLayout)Changes
Result
https://user-images.githubusercontent.com/47522946/210212706-89e5e3bc-42d9-4587-9c6a-67a5868ba7ec.mov
Proposal This causes by the function
this.form.scrollToinsideonFixTheErrorsLinkPressedreturn undefinded. Solution Remove the block of code:or add the check if the
this.form.scrollTois a function before using it (typeof this.form.scrollTo === ‘function’)https://user-images.githubusercontent.com/16502320/210211504-c4ea89f6-8736-4629-a94e-7dae20eb4de5.mov