-
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
[TS migration] Migrate 'Form' component to TypeScript #32992
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
[diff] external = difft
src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js
Outdated
Show resolved
Hide resolved
# Conflicts: # src/pages/settings/Wallet/WalletPage/WalletPage.js
FYI: #33960 can cause some conflicts, but I think, they will be easy to resolve |
@kbecciv @allroundexperts Should be fixed now, thanks for reporting |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-01-25.at.5.27.06.AM.movAndroid: mWeb ChromeScreen.Recording.2024-01-25.at.5.26.02.AM.moviOS: NativeScreen.Recording.2024-01-25.at.5.24.31.AM.moviOS: mWeb SafariScreen.Recording.2024-01-25.at.5.22.37.AM.movMacOS: Chrome / Safariscreen-recording-2024-01-25-at-51331-am_OD80Ca13.mp4MacOS: DesktopScreen.Recording.2024-01-25.at.5.20.18.AM.mov |
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 looking pretty good to me. The drafts are working fine along with the error handling.
We did not find an internal engineer to review this PR, trying to assign a random engineer to #31972 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
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.
Okay! I think this makes sense, and it looks like it tests well. I'm going to go ahead and merge and we can monitor to see how it goes.
Looks like there are some follow up pieces noted in the discussions too, so we should just make sure those happen when they can!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
@mountiny Since this was a pretty big PR, (I spent quite some time on it), Is it possible to raise the review compensation to $500? Thanks! |
I think thats valid |
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.
Thanks for working on this PR. Some feedback I'd like to see addressed in a follow-up PR, if possible.
The Errors
type used by FormProvider
is just a Record<string, string>
. Server errors can prettymuch be any string mapped to any string, but client errors (like the ones returned by the function passed to FormProvider
's validate
prop), should be an object where the keys are strictly one of the inputID
values for one of the child InputWrapper
components, and the values should strictly be a localized string.
I encountered this because I used a constant for my form's inputIDs:
<FormProvider
...
validate={() => {
if (reason) {
return {};
}
return {
// TS error here, because {"reason": string} is not assignable to Record<string, string>
[CONST.EXIT_SURVEY.REASON_INPUT_ID]: translate('common.error.fieldRequired');
};
}}
>
<InputWrapper
InputComponent={RadioButtons}
inputID={CONST.EXIT_SURVEY.REASON_INPUT_ID}
...
/>
</FormProvider
I can fix this with some type widening:
return {
// TS error here, because {"reason": string} is not assignable to Record<string, string>
- [CONST.EXIT_SURVEY.REASON_INPUT_ID]: translate('common.error.fieldRequired');
+ [CONST.EXIT_SURVEY.REASON_INPUT_ID as string]: translate('common.error.fieldRequired');
};
But we're kind of missing an opportunity here to capture the fact that we know what keys are valid in the object to be returned from validate
. I think we can / should standardize on using constants for form inputIDs. @blazejkustra What do you think?
That should be a quick fix! @roryabraham can you create a ticket for that? /** Callback to validate the form */
validate?: (values: OnyxFormValuesFields<TFormID>) => Errors;
// after
validate?: (values: OnyxFormValuesFields<TFormID>) => Record<keyof OnyxFormValuesFields<TFormID>, TranslationPaths>;
Shouldn't it be a translation path instead of a localized string? {
[CONST.EXIT_SURVEY.REASON_INPUT_ID]: 'common.error.fieldRequired'; // not `translate('common.error.fieldRequired');`
};
I love standardization and constants, so I'm all for it 😆 @roryabraham can you create a ticket for that too? I think we should be able to do it in one PR (there are 116 results in 52 files for |
Looks like you are right. I was using a translated string, but I think that I was doing it wrong. All the more reason these changes will be good 😉 |
@blazejkustra I created #35318, can you comment for assignment plz? |
🚀 Deployed to staging by https://github.com/dangrous in version: 1.4.33-0 🚀
|
@blazejkustra
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.4.33-5 🚀
|
Details
Migration of
Form
to Typescript.Fixed Issues
$ #31972
PROPOSAL: N/A
Tests
Workspace new room:
+
button > PressStart chat
> Switch to# Room
-
Room name:
Settings
> PressRoom name
-
Edit room name without change:
Waypoint editor
+
button > Request moneyDistance
tabSave
ValidationStep
011401533
, Account number:1111222233331111
> ContinueAddDebitCardPage:
Full list of forms with detailed test steps in PRs
https://github.com//issues/28878 https://github.com//issues/28879 https://github.com//issues/28877 https://github.com//issues/28876 https://github.com//issues/28875 https://github.com//issues/28874 https://github.com//issues/28873 https://github.com//issues/28872 https://github.com//issues/28871 https://github.com//issues/28870 https://github.com//issues/29997 https://github.com//issues/29998 https://github.com//issues/30000 https://github.com//issues/30002 https://github.com//issues/30003 https://github.com//issues/30004 https://github.com//issues/30006 https://github.com//issues/30008 https://github.com//issues/31559 https://github.com//issues/31562 https://github.com//issues/31566 https://github.com//issues/31565 https://github.com//issues/31612 https://github.com//issues/33356 https://github.com//issues/30305 https://github.com//issues/30306 https://github.com//issues/30307 https://github.com//issues/30308 https://github.com//issues/30310 https://github.com//issues/30311 https://github.com//issues/30312 https://github.com//issues/30314 https://github.com//issues/30316 https://github.com//issues/31561 https://github.com//issues/31563 https://github.com//issues/31564 https://github.com//issues/31560 https://github.com//issues/32064Offline tests
N/A
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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.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
Android: Native
android.webm
Android: mWeb Chrome
android-web.webm
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-web.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov