[TS Migration] Improve Form
Details
- Fixed ✅
onPressis defined to receive a singleGestureResponderEventargument, but in reality it can receive different treatment depending on the input that it's used with - Fixed ✅ Currently, the object returned by validate is just a
Record<string, string>, but we know that the return type should be a map of formInputID: translationKey - Done ✅ Use constants for a form inputIDs
- Fixed ✅
FormValueTypeis defined loosely asstring | boolean | Date, but I'd think that the value type would depend on which form is being referenced. - Done ✅ NAB improvement that would be nice to see is if we could eliminate the need to define every form key and type twice
Fixed Issues
$ https://github.com/Expensify/App/issues/35318 PROPOSAL: https://github.com/Expensify/App/pull/32992#issuecomment-1914296224
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!
Hey @blazejkustra Could you take a look a this PR too?
@fabioh8010 I discussed it with @barttom on slack and he prepared another PR on top of it 👍
Creating short & easy to review PRs is my passion 🤣
I changed the structure of files as you suggested @fabioh8010 @roryabraham
@abdulrahuman5196 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]
@abdulrahuman5196 I recommend reading through resolved comments, and linked issue. A lot of details and context is there. In case of any questions let me know here or on Slack.
Sure will go through this in my morning
@abdulrahuman5196 Bump
Hi, @blazejkustra I understand the requirements.
Doesn't it seem odd to have the form types in a separate folder or files? I don't see much re-usability of the page specific files. Wouldn't it be good if have the same in the page file itself like the props type?
Do let me know your thought process? And kindly check on the file conflicts as well.
Wouldn't it be good if have the same in the page file itself like the props type?
Not a bad idea @abdulrahuman5196! Curious what @blazejkustra and @fabioh8010 think but it's worth considering.
I guess one downside is that in defining the Onyx values type you'd have to import form types from all over the codebase, which could get a bit messy.
These form types don't belong only to its form components, but also to Onyx because they are Onyx Values in the end. If we decide to keep the form types in each component, we will have the problem @roryabraham mentioned (we will need to import types from all over the codebase to pass to OnyxValues), and we will need to import the generic Form in each component that declares its Form type. I personally think this move has more downsides than upsides.
@abdulrahuman5196 Can you please prioritize this issue? It gets a lot of conflicts and type errors with changes on main, if you have any questions. I'm here to assist you 😄
Hi, @blazejkustra Sorry, Didn't see the last comment. Will re-review now
@blazejkustra I did check on high level and have no further comments.
But given the PRs size and test range, I would need probability today and tomorrow(hopefully today alone) to check if anything is causing issues. Will on the same.
Could you kindly fix the lint code meanwhile
@abdulrahuman5196 Prettier fixed ✅ Thanks for a quick response!
FYI: Working on this. Will close out sooner. Meanwhile kindly check on conflicts and lint arised(I assume this PR might be prune to more if we leave it out).
@abdulrahuman5196 I just merged the newest main and adjusted the code after bank refactor 😮💨
@blazejkustra I just completed testing all the flows mentioned. Came here to comment the checklist.
Seems now I have to test the new bank change as well. 😞
Reviewer Checklist
- [x] I have verified the author checklist is complete (all boxes are checked off).
- [x] I verified the correct issue is linked in the
### Fixed Issuessection above - [x] I verified testing steps are clear and they cover the changes made in this PR
- [x] I verified the steps for local testing are in the
Testssection - [x] I verified the steps for Staging and/or Production testing are in the
QA stepssection - [x] I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- [x] I verified the steps for local testing are in the
- [x] I checked that screenshots or videos are included for tests on all platforms
- [x] I included screenshots or videos for tests on all platforms
- [x] I verified tests pass on all platforms & I tested again on:
- [x] Android: Native
- [x] Android: mWeb Chrome
- [x] iOS: Native
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] MacOS: Desktop
- [x] If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- [x] I verified proper code patterns were followed (see Reviewing the code)
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReportand notonIconClick). - [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />. - [x] I verified that comments were added to code that is not self explanatory
- [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- [x] I verified any copy / text shown in the product is localized by adding it to
src/languages/*files and using the translation method - [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
- [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the
Waiting for Copylabel for a copy review on the original GH to get the correct copy. - [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
- [x] I verified the JSDocs style guidelines (in
STYLE.md) were followed
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I verified that this PR follows the guidelines as stated in the Review Guidelines
- [x] I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- [x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- [x] If a new component is created I verified that:
- [x] A similar component doesn't exist in the codebase
- [x] All props are defined accurately and each prop has a
/** comment above it */ - [x] The file is named correctly
- [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- [x] The only data being stored in the state is data necessary for rendering and nothing else
- [x] For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - [x] Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - [x] All JSX used for rendering exists in the render method
- [x] The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- [x] If any new file was added I verified that:
- [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- [x] If the PR modifies the form input styles:
- [x] I verified that all the inputs inside a form are aligned with each other.
- [x] I added
Designlabel so the design team can review the changes.
- [x] If a new page is added, I verified it's using the
ScrollViewcomponent to make it scrollable when more elements are added to the page. - [x] If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots/Videos
Android: Native
https://github.com/Expensify/App/assets/46707890/4cd63c16-6f0b-46e8-b096-153044da9707
https://github.com/Expensify/App/assets/46707890/938be949-14eb-416c-830c-de0ce1ac8b2f
https://github.com/Expensify/App/assets/46707890/7f8762d1-ce76-46be-9ad6-60e16a5eb5fd
Android: mWeb Chrome
https://github.com/Expensify/App/assets/46707890/7d50e08a-e199-4efe-93e8-7b86a8515f45
https://github.com/Expensify/App/assets/46707890/6bdaab55-3dc0-4a09-916a-85abd54234de
https://github.com/Expensify/App/assets/46707890/5fafd561-d4f0-4354-acfe-d6783d3dac68
iOS: Native
https://github.com/Expensify/App/assets/46707890/70674f68-a3da-4423-a559-52415141fedd
https://github.com/Expensify/App/assets/46707890/a8308d6b-587f-4b07-9049-d0a7358575e9
https://github.com/Expensify/App/assets/46707890/fa9de44b-8c31-49ce-ad6c-35c516f29c8e
iOS: mWeb Safari
https://github.com/Expensify/App/assets/46707890/c7de020f-494f-423a-969f-0dfe5207b92e
https://github.com/Expensify/App/assets/46707890/347d8e23-3017-4665-b153-19dd3faeabf1
https://github.com/Expensify/App/assets/46707890/6b228471-eff0-49ec-96da-059f0900332f
MacOS: Chrome / Safari
https://github.com/Expensify/App/assets/46707890/8f8bb149-8887-448f-9f21-7e76a6a05d02
https://github.com/Expensify/App/assets/46707890/e430e841-deeb-41dd-9836-b31887233139
https://github.com/Expensify/App/assets/46707890/0525e539-8dbd-43ef-994f-1b46129e4b12
MacOS: Desktop
https://github.com/Expensify/App/assets/46707890/673c503c-0d82-4316-a56f-56be1d7fd1a0
https://github.com/Expensify/App/assets/46707890/b0d71d3a-6e6a-4ba2-803e-36482991369d
https://github.com/Expensify/App/assets/46707890/d2866406-1528-4458-ac7b-39110be28abc
Going to merge this to avoid conflicts. Would love to see follow-ups for the couple concerns listed in my last review
:hand: 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/roryabraham in version: 1.4.42-0 🚀
| platform | result |
|---|---|
| 🤖 android 🤖 | success ✅ |
| 🖥 desktop 🖥 | success ✅ |
| 🍎 iOS 🍎 | success ✅ |
| 🕸 web 🕸 | success ✅ |
@blazejkustra @abdulrahuman5196 can we ignore "Full list of forms with detailed test steps"?
I think you can test just some of forms, that should be enough
🚀 Deployed to production by https://github.com/chiragsalian in version: 1.4.42-5 🚀
| platform | result |
|---|---|
| 🤖 android 🤖 | success ✅ |
| 🖥 desktop 🖥 | success ✅ |
| 🍎 iOS 🍎 | success ✅ |
| 🕸 web 🕸 | success ✅ |