-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix scroll on native when going back to the login page #25590
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6720f6d
split LoginForm into base and index.js files
joh42 f08ae20
added newline at file end
joh42 4b1de5c
exposed scrollPageToTop in the SignInPageLayout
joh42 1f7fe9a
started passing scrollPageToTop to the LoginForm
joh42 5350167
exposed the input focus state of the BaseLoginForm with isInputFocused
joh42 ba3e8d9
added native scrolling logic for the LoginForm
joh42 9faa879
added PropTypes import
joh42 5734483
fixed issues found by linter
joh42 3548deb
fixed prettier diff
joh42 770c9aa
another prettier fix
joh42 1c36f19
invisible prettier fix lol
joh42 0371d6e
Merge branch 'Expensify:main' into fix/23718-2
joh42 6a861a0
set default value of scrollPageToTop to undefined
joh42 710f596
updated scrollPageToTop default prop to undefined
joh42 9d9879e
resolved merge conflicts (signed)
joh42 c2fc0b0
resolved more merge conflicts
joh42 a83d334
Merge branch 'Expensify:main' into fix/23718-2
joh42 0dae6bc
removed duplicate defaultProps
joh42 215d6fa
removed redundant comment
joh42 2661fb8
Merge branch 'main' into fix/23718-2
joh42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import BaseLoginForm from './BaseLoginForm'; | ||
|
||
const propTypes = { | ||
/** Function used to scroll to the top of the page */ | ||
scrollPageToTop: PropTypes.func, | ||
}; | ||
const defaultProps = { | ||
scrollPageToTop: undefined, | ||
}; | ||
|
||
function LoginForm(props) { | ||
return ( | ||
<BaseLoginForm | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
LoginForm.displayName = 'LoginForm'; | ||
LoginForm.propTypes = propTypes; | ||
LoginForm.defaultProps = defaultProps; | ||
|
||
export default LoginForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, {useEffect, useRef} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import BaseLoginForm from './BaseLoginForm'; | ||
import AppStateMonitor from '../../../libs/AppStateMonitor'; | ||
|
||
const propTypes = { | ||
/** Function used to scroll to the top of the page */ | ||
scrollPageToTop: PropTypes.func, | ||
}; | ||
const defaultProps = { | ||
scrollPageToTop: undefined, | ||
}; | ||
|
||
function LoginForm(props) { | ||
const loginFormRef = useRef(); | ||
const {scrollPageToTop} = props; | ||
|
||
useEffect(() => { | ||
if (!scrollPageToTop) { | ||
return; | ||
} | ||
|
||
const unsubscribeToBecameActiveListener = AppStateMonitor.addBecameActiveListener(() => { | ||
const isInputFocused = loginFormRef.current && loginFormRef.current.isInputFocused(); | ||
if (!isInputFocused) { | ||
return; | ||
} | ||
|
||
scrollPageToTop(); | ||
}); | ||
|
||
return unsubscribeToBecameActiveListener; | ||
}, [scrollPageToTop]); | ||
|
||
return ( | ||
<BaseLoginForm | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={(ref) => (loginFormRef.current = ref)} | ||
/> | ||
); | ||
} | ||
|
||
LoginForm.displayName = 'LoginForm'; | ||
LoginForm.propTypes = propTypes; | ||
LoginForm.defaultProps = defaultProps; | ||
|
||
export default LoginForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The props are sent to the BaseLoginForm here: https://github.com/joh42/expensify-app/blob/2661fb84b0e3c4921aafa9fc3fe3e794be602d88/src/pages/signin/LoginForm/index.native.js#L38
But {scrollPageToTop, ...props} could work if that's preferred