-
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
Clicking on 'fix the errors' button first input border is cut off at the top #12942
Comments
Triggered auto assignment to @MitchExpensify ( |
https://stackoverflow.com/c/expensify/questions/14418
|
Hmmm its similar but I guess technically different bugs? This PR made changes to the form component. I'm not sure if this was an issue before or after this PR because we only tested it on forms that did not require a scroll |
Taking a look! |
IMO this is ok and a known drawback of using the |
ProposalAs mentioned by @luacmartins, this is a known drawback of using focus method. We can therefore, scroll to the input position - an offset of 10. diff --git a/src/components/Form.js b/src/components/Form.js
index 4734381bc..afdf1a06f 100644
--- a/src/components/Form.js
+++ b/src/components/Form.js
@@ -1,6 +1,6 @@
import lodashGet from 'lodash/get';
import React from 'react';
-import {ScrollView, View} from 'react-native';
+import {ScrollView, View, findNodeHandle} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
@@ -78,8 +78,8 @@ class Form extends React.Component {
};
this.inputRefs = {};
+ this.scrollViewRef = null;
this.touchedInputs = {};
-
this.setTouchedInput = this.setTouchedInput.bind(this);
this.validate = this.validate.bind(this);
this.submit = this.submit.bind(this);
@@ -249,6 +249,7 @@ class Form extends React.Component {
style={[styles.w100, styles.flex1]}
contentContainerStyle={styles.flexGrow1}
keyboardShouldPersistTaps="handled"
+ ref={ref => this.scrollViewRef = ref}
>
<View style={[this.props.style]}>
{this.childrenWrapperWithProps(this.props.children)}
@@ -263,6 +264,9 @@ class Form extends React.Component {
const errors = !_.isEmpty(this.state.errors) ? this.state.errors : this.props.formState.errorFields;
const focusKey = _.find(_.keys(this.inputRefs), key => _.keys(errors).includes(key));
this.inputRefs[focusKey].focus();
+ this.inputRefs[focusKey].measureLayout(findNodeHandle(this.scrollViewRef), (x, y) => {
+ this.scrollViewRef.scrollTo({x, y: y - 10, animated: true});
+ });
}}
containerStyles={[styles.mh0, styles.mt5]}
enabledWhenOffline={this.props.enabledWhenOffline}
ResultSimulator.Screen.Recording.-.iPhone.13.-.2022-11-26.at.18.07.48.mp4 |
Hey people! Please check the linked PRs before working on proposals! I grabbed this last week and the PR has been around since wednesday or so 😬 |
Issue not reproducible during KI retests. (First week) |
@Gonals, @MitchExpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry! |
@Gonals, @MitchExpensify 10 days overdue. I'm getting more depressed than Marvin. |
@Gonals, @MitchExpensify 12 days overdue now... This issue's end is nigh! |
This issue has not been updated in over 14 days. @Gonals, @MitchExpensify eroding to Weekly issue. |
Yep! |
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:
Expected Result:
The first input should NOT be cut off from above
Actual Result:
The first input is cut off from above
Workaround:
Unknown
Platform:
Where is this issue occurring?
Version Number: 1.2.30-0
Reproducible in staging?: y
Reproducible in production?: y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
https://user-images.githubusercontent.com/43996225/203416843-0f7ba9d7-ad2e-4f50-aab2-2aa895ce5b47.mp4
Expensify/Expensify Issue URL:
Issue reported by: Applause internal team
Slack conversation:
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: