App: [HOLD for payment 2022-05-24] [$1000] [HOLD for payment after regression testing] Refactor Picker to be compatible with Form
With the implementation of our new Form component we need to refactor Picker to be Form compatible. Here are the changes that need to be made:
- An optional
isFormInputprop. - If
isFormInputistrue, require ainputIDprop. Use getInputIDPropTypes to enforce this propType rule. - Add an optional
shouldSaveDraftprop. Defaults tofalse. - Make the
valueprop optional. - In the input’s
onBlurmethod, callprops.onBlur(). - In the input’s
onChangemethod (or equivalent e.g. onTextChange, etc), callprops.onChange(). - Remove the
hasErrorprop. - Add an optional
errorTextprop. Defaults to an empty string. - Update the error message to display if
errorTextis truthy. - Update the inline error display style so it is left aligned with the label and input value. See example image for TextInput:

- Make sure that
props.refis attached to the appropriate DOM node. This could involve forwarding the ref to a child component. This is important so we can callref.focus(). - Add the input to the test Form stories and make sure that it works. You can check this by running
npm run storybookand testing the component in the example form. - 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: 93 (82 by maintainers)
Just noting for the record that @parasharrajat needs a reporting bonus for reporting the regression here. The regression issue is here, but we decided to use this issue to manage everything to avoid confusion.
cc: @laurenreidexpensify @stitesExpensify
I found a solution to blur regression
We need to fire
onClosealong withonBlur.No, that has been solved and the PR is currently in review!
@parasharrajat all done - sorry about that!
@LucioChavezFuentes payment has been issued 👍🏽
Ah, yes! That title doesn’t update automatically. I’ve updated this to reflect the correct amount.
There was a regression on the PR and a temporary fix was deployed. We are still looking for a better permanent fix. Not sure if this changes the payment schedule or not.
Today I am available but I will be out for a week starting tomorrow. I apologize for the incoveninece this may arise.
Update, I only need to test my
Pickeron IOS and Mac, I am currently creating a Mac mini M1 instance on Scaleway.Guys, I don’t think I can deliver a Pull Request on Friday but until next week. I apologize for the inconvenience.
About scrolling on
focus( )I think it depends on tags or components you are trying to focus. On Web,Pickerrenders a<select>and I confirm executingfocus ( )on it does make a scroll. Meanwhile I tried to focus on a<div>and it doesn’t make scroll.@rushatgabhane hmm I remember testing it and having the input scroll into view on all devices. We are planning on using focus to simplify the implementation of scrolling into view.
Yes, it is! But it requires that the ref expose a
focus()method.I decided to check Picker and modify a little its forwardRef implementation inside mode_modules, and I finally got the DOM instance with
focus( )passing ref topickerProps, it still does not show the picker’s dropdown list when I click ‘fix errors’ but it proves Picker does not forward ref, at least at the version we are using.Original code inside
node_modules/@react-native-picker/picker/js/Picker.web.jsModified code inside
node_modules/@react-native-picker/picker/js/Picker.web.jsPassing ref to
pickerProps:DOM ref available:
**handleOpen executes when click ‘fix the errors’, which is passed on
onFocuspickerProps **What do you gus think?
I had an issue rendering
Pickercomponent insideForm.stories.js. But I fix it by installing@storybook/addon-react-native-webas devDependency and add it on.storybook\main.jsonaddonsarray. The problem was related toNo loader found for this type of fileand it is documented in storybook, more info: https://github.com/storybookjs/addon-react-native-web/blob/main/README.md#common-issues. Is it OK to install this devDependecy?packaje.json.storybook\main.jsThank you! I submitted my proposal on Upwork. I plan to finish the issue on Wednesday, 9th February.