-
Notifications
You must be signed in to change notification settings - Fork 3.2k
16185 - Migrate PDFPasswordForm.js to function component #24290
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
16185 - Migrate PDFPasswordForm.js to function component #24290
Conversation
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.
Overall looks good 👍
const textInputRef = useRef(null); | ||
|
||
useEffect(() => { | ||
if (!props.isFocused || !textInputRef.current) return; |
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.
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) { |
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.
Let's destruct the props
textInputRef.current.focus(); | ||
}, [props.isFocused]); | ||
|
||
const getErrorText = () => { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline this in PDFInfoMessage's onShowForm
const containerStyle = isSmallScreenWidth ? [styles.flex1, styles.w100] : styles.pdfPasswordForm.wideScreenWidth; | ||
|
||
return ( | ||
<> |
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.
Remove this fragment
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
LGTM! 🚀
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.
Looks good just a couple of small comments.
return shouldShowForm ? ( | ||
<ScrollView | ||
keyboardShouldPersistTaps="handled" | ||
style={styles.pdfPasswordForm(isSmallScreenWidth)} |
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.
This should be something like getPDFPasswordFormStyle()
. Functions usually are named for what they do or return.
return ''; | ||
} | ||
})(); |
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.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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