16185 - Migrate PDFPasswordForm.js to function component#24290
16185 - Migrate PDFPasswordForm.js to function component#24290marcaaron merged 9 commits intoExpensify:mainfrom
Conversation
| const textInputRef = useRef(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!props.isFocused || !textInputRef.current) return; |
There was a problem hiding this comment.
| if (!props.isFocused || !textInputRef.current) return; | |
| if (!props.isFocused) { | |
| return; | |
| } | |
| if (!textInputRef.current) { | |
| return; | |
| } |
NAB I think it's more readable
| } | ||
| this.textInputRef.focus(); | ||
| } | ||
| function PDFPasswordForm(props) { |
| textInputRef.current.focus(); | ||
| }, [props.isFocused]); | ||
|
|
||
| const getErrorText = () => { |
There was a problem hiding this comment.
Can we define the errorText without defining the function since this function is only used once.
| submitPassword() { | ||
| if (!this.validate()) { | ||
| return; | ||
| const updatePassword = (passwrd) => { |
There was a problem hiding this comment.
| const updatePassword = (passwrd) => { | |
| const updatePassword = (newPassword) => { |
NAB passwrd looks like a typo, it may be confusing with password. newPassword looks more as an intended change.
| const showForm = () => { | ||
| setShouldShowForm(true); | ||
| }; |
There was a problem hiding this comment.
Inline this in PDFInfoMessage's onShowForm
| const containerStyle = isSmallScreenWidth ? [styles.flex1, styles.w100] : styles.pdfPasswordForm.wideScreenWidth; | ||
|
|
||
| return ( | ||
| <> |
There was a problem hiding this comment.
This is not resolved yet. Remove the extra <> and </> (then npm run prettier)
| const containerStyle = isSmallScreenWidth ? [styles.flex1, styles.w100] : styles.pdfPasswordForm.wideScreenWidth; | ||
|
|
||
| return ( | ||
| <> |
There was a problem hiding this comment.
This is not resolved yet. Remove the extra <> and </> (then npm run prettier)
| onPasswordFieldFocused(false); | ||
| }; | ||
|
|
||
| const showForm = () => setShouldShowForm(true); |
There was a problem hiding this comment.
What I meant is to pass the function directly to PDFInfoMessage without defining it.
<PDFInfoMessage onShowForm={() => setShouldShowForm(true)} />| {shouldShowForm ? ( | ||
| <ScrollView | ||
| keyboardShouldPersistTaps="handled" | ||
| style={isSmallScreenWidth ? [styles.flex1, styles.w100] : styles.pdfPasswordForm.wideScreenWidth} |
There was a problem hiding this comment.
| style={isSmallScreenWidth ? [styles.flex1, styles.w100] : styles.pdfPasswordForm.wideScreenWidth} | |
| style={styles.pdfPasswordForm(isSmallScreenWidth)} |
And in styles.js
pdfPasswordForm: (isSmallScreenWidth) => ({
width: isSmallScreenWidth ? '100%' : 350,
...(isSmallScreenWidth && flex.flex1),
}),
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
|
@Skalakid I'm having trouble testing this in Native. I'm not sure if this is related to this PR or something from my end, can you please double check this is working well from your side? I'm getting an error |
|
It looks that we may have another problem in main https://expensify.slack.com/archives/C01GTK53T8Q/p1691851369441659 that is blocking testing. |
marcaaron
left a comment
There was a problem hiding this comment.
Looks good just a couple of small comments.
| return shouldShowForm ? ( | ||
| <ScrollView | ||
| keyboardShouldPersistTaps="handled" | ||
| style={styles.pdfPasswordForm(isSmallScreenWidth)} |
There was a problem hiding this comment.
This should be something like getPDFPasswordFormStyle(). Functions usually are named for what they do or return.
|
|
||
| return ''; | ||
| } | ||
| })(); |
There was a problem hiding this comment.
Maybe we can just do a useMemo() here if we are going to use an IIFE.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.3.56-0 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|

Details
Fixed Issues
$ #16185
PROPOSAL: #16185
Tests
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
mWeb-chrome.mov
Mobile Web - Safari
mWeb-safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
andorid.mov