App: [HOLD for payment 2022-05-20] [$500] Refactor StatePicker to be compatible with Form

With the implementation of our new Form component we need to refactor StatePicker to be Form compatible. Here are the changes that need to be made:

  1. An optional isFormInput prop.
  2. If isFormInput is true, require a inputID prop. Use getInputIDPropTypes to enforce this propType rule.
  3. Add an optional shouldSaveDraft prop. Defaults to false.
  4. Make the value prop optional.
  5. In the input’s onBlur method, call props.onBlur().
  6. Rename the input’s onChange method to onInputChange.
  7. In the input’s onInputChange method (or equivalent e.g. onTextChange, etc), call props.onInputChange().
  8. Remove the hasError prop.
  9. Add an optional errorText prop. Defaults to an empty string.
  10. Update the error message to display if errorText is truthy.
  11. Update the inline error display style so it is left aligned with the label and input value. See example image for TextInput: Screen Shot 2022-02-02 at 10 37 38 AM
  12. Make sure that props.ref is attached to the appropriate DOM node. This could involve forwarding the ref to a child component. This is important so we can call ref.focus().
  13. Add the input to the test Form stories and make sure that it works. You can check this by running npm run storybook and testing the component in the example form.
  14. Remove any unused code.

There’s an example of a refactor to TextInput in this PR.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 48 (41 by maintainers)

Most upvoted comments

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.57-17 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2022-05-20. 🎊

Hey @jayeshmangwani! Sure, feel free to pick it up and submit a PR. I’ll re-add the labels and re-assign the relevant people to this issue. Thanks for the interest and picking this up.

@MitchExpensify Please disregard my comment above about removing this job. We are making it External again and @jayeshmangwani will work on this.

The holding PR is merged! We can start working on this 🎉

Paid @jayeshmangwani , thank you very much!

@jayeshmangwani Can you apply to this Upwork Job please? I had to abandon the original job so we’ll use this new posting to issue payment (invited you to the new job @parasharrajat)

Sure I am applying

@jayeshmangwani Can you apply to this Upwork Job please? I had to abandon the original job so we’ll use this new posting to issue payment (invited you to the new job @parasharrajat)

Ok Great. @jayeshmangwani this is urgent so I am hoping that PR will be ready by Monday. Thanks for taking it up.

🎀 👀 🎀 C+ reviewed

📣 @parasharrajat You have been assigned to this job by @luacmartins! Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

@luacmartins is there any chance it can be External again?

I saw this issue a few hours back and I was working on this and I have done all the changes that are mentioned I was testing these changes in the app, here are videos

[Form stories]

https://user-images.githubusercontent.com/35371050/164755723-0c8407b0-afe1-4e9b-9087-5f403dfa5ca7.mov

DebitCardPage Before Changes

https://user-images.githubusercontent.com/35371050/164756039-58e41b4c-756e-4d1b-9299-0948c837f0ec.mov

DebitCardPage After Changes

https://user-images.githubusercontent.com/35371050/164756113-2f24d044-68fd-4136-8b4a-44b6639d7c6a.mov

Not overdue, just became ready to work on

Looks like we’re holding on https://github.com/Expensify/App/issues/7535 before starting this

Good eye @rushatgabhane. We are already waiting for some issue @sig5 is having.

@sig5 @parasharrajat Before starting on this one, we need to first merge a PR for Refactor Picker right?

Sending it! @MitchExpensify could you please hire @sig5 ?