-
Notifications
You must be signed in to change notification settings - Fork 3k
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
statepicker refactored to compatible with form #8758
statepicker refactored to compatible with form #8758
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
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.
Please attach test videos for all platforms and sign the CLA.
- Missing QA steps.
src/components/StatePicker.js
Outdated
value={props.value} | ||
label={props.label || props.translate('common.state')} | ||
hasError={props.hasError} | ||
errorText={props.errorText} | ||
onBlur={props.onBlur} | ||
containerStyles={props.containerStyles} |
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.
Did you define this prop? I don't think we need this.
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.
Yes I have defined this, onBlur was in task's requirement, and containerStyles added for styling the picker
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.
I don't see the prop definitions for these.
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.
yes you are right, I have not defined containerStyles in props, and it was also not included in the task to add, so I think I should remove containerStyles from here
src/components/StatePicker.js
Outdated
placeholder={{value: '', label: '-'}} | ||
items={STATES} | ||
onInputChange={props.onChange} | ||
onInputChange={props.onInputChange} | ||
value={props.value} | ||
label={props.label || props.translate('common.state')} | ||
hasError={props.hasError} |
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 removed. Right?
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.
I think we have to update the name only from onChange to onInputChange, if i am removing this then picker is not working
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.
I meant the hasError. Review comments refer to the line on which they are tagged.
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.
I have removed hasError from props only, let me remove hasError from here too
src/components/StatePicker.js
Outdated
|
||
/** Error text to display */ | ||
errorText: PropTypes.string, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
label: '', | ||
value: '', |
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 pass undefined
. ''
is still a value. I am not sure if Picker checks for truthy value before binding it.
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.
an empty string will work here, we are checking this at 2 places
App/src/components/InlineErrorText.js
Lines 20 to 22 in ad637d3
if (_.isEmpty(props.children)) { | |
return null; | |
} |
const hasError = !_.isEmpty(this.props.errorText); |
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.
I am talking about the value.
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.
yes value will be undefined here
I have read the CLA Document and I hereby sign the CLA |
Co-authored-by: Rajat Parashar <parasharrajat@users.noreply.github.com>
value={this.state.incorporationState} | ||
errorText={this.getErrorText('incorporationState')} | ||
hasError={this.getErrors().incorporationState} |
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.
Shouldn't we remove these?
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 pointing out these changes, Yes I need to change all these places where we are using StatePicker,
hasError={Boolean(props.errors.state)} |
hasError={this.getErrors().incorporationState} |
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.
Did you run npm run lint
? Can you please proactively test your changes? Please ping me when you think it's fully ready.
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.
@@ -72,7 +72,6 @@ const AddressForm = props => ( | |||
value={props.values.state} | |||
onChange={value => props.onFieldChange({state: value})} |
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.
We have to rename onChange
to onInputChange
value={this.state.incorporationState} | ||
hasError={this.getErrors().incorporationState} | ||
errorText={this.getErrorText('incorporationState')} |
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.
The incorporationState
key is not defined here.
src/stories/Form.stories.js
Outdated
inputID="pickState" | ||
shouldSaveDraft | ||
isFormInput | ||
/> |
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.
Please add a top margin like the other inputs
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.
we have not defined a style prop for StatePicker, we need to create containerStyles prop here
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.
or you can just wrap it in a View like we do in all calls of StatePicker
, e.g.
App/src/pages/ReimbursementAccount/CompanyStep.js
Lines 287 to 294 in fdd741f
<View style={styles.mt4}> | |
<StatePicker | |
label={this.props.translate('companyStep.incorporationState')} | |
onChange={value => this.clearErrorAndSetValue('incorporationState', value)} | |
value={this.state.incorporationState} | |
hasError={this.getErrors().incorporationState} | |
/> | |
</View> |
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.
Ohkay
We should also define |
|
I mean the Test steps in your PR description, i.e.:
|
Thank you for the update, I have updated the description please check whenever you get the time and please let me know if I have missed any point as it's my first PR in the repo. |
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.
The code looks good and tests well. You will have to add the QA steps before we can merge this. @jayeshmangwani
Note: QA team can't run run storybook using npm run storybook
so use Go to https://staging.new.expensify.com/docs/index.html for storybook
cc: @luacmartins
PR Reviewer Checklist
- I verified the PR has a small number of commits behind
main
- I verified the correct issue is linked in the
### Fixed Issues
section above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the testing environment is mentioned in the test steps
- I verified testing steps cover success & fail scenarios (if applicable)
- I checked that screenshots or videos are included for tests on all platforms
- I verified tests pass on all platforms & I tested again on:
- iOS / native
- Android / native
- iOS / Safari
- Android / Chrome
- MacOS / Chrome
- MacOS / Desktop
- I verified there are no console errors related to changes in this PR
- I verified proper code patterns were followed (see Reviewing the code)
- I verified comments were added when the code was not self explanatory
- I verified any copy / text shown in the product was added in all
src/languages/*
files (if applicable) - I verified proper naming convention for platform-specific files was followed (if applicable)
- I verified style guidelines were followed
- I verified the JSDocs style guidelines (in
STYLE.md
) were followed
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components are not impacted by changes in this PR (i.e. if the PR modifies a shared library or component like
Avatar
, I verified the components usingAvatar
are working as expected) - I verified the UI performance was not affected (the performance is the same than
main
branch) - If a new component is created I verified that a similar component doesn't exist in the codebase
🎀 👀 🎀 C+ reviewed
@parasharrajat added QA steps |
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 the changes. Left one more comment.
@@ -198,6 +210,7 @@ InputError.args = { | |||
accountNumber: '', | |||
pickFruit: '', | |||
pickAnotherFruit: '', | |||
pickState: '', |
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 also add a non-empty default value for pickState
here?
During my testing, the default value didn't seem to work properly on page load.
storybook.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.
I think we have to add 1 more prop in StatePicker for this change, we need to pass defaultValue to make it work
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.
I have added a default value for pickState, but we also have to pass defaultValue in StatePicker component, please let me know your thought on this
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.
That sounds similar to what I'm doing in the Datepicker refactor. If that's the case I think it's fine :)
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, then its fine
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.
Hmm the default value still doesn't load for me. Can you please check?
default.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.
@luacmartins we need to pass defaultValue as a prop in StatePicker here
defaultValue={props.defaultValue}
as this value is being used in the BasePicker
@jayeshmangwani Please merge main as there are conflicts. Thanks. |
@parasharrajat latest main branch merged, |
I can't test it. The storybook is not working for me. https://expensify.slack.com/archives/C01GTK53T8Q/p1651081332743029 Possible solution https://expensify.slack.com/archives/C01GTK53T8Q/p1651082528577659?thread_ts=1651081332.743029&cid=C01GTK53T8Q |
Yes this solution is working for me, I have tested in storybook |
shouldSaveDraft: false, | ||
isFormInput: false, | ||
inputID: undefined, | ||
onBlur: () => {}, |
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.
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.
src/components/StatePicker.js
Outdated
value={props.value} | ||
defaultValue={props.defaultValue} |
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.
I think we should pass either value
or defaultValue
but not both.
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.
now added conditional value here, if the value is available then the value will be used otherwise defaultValue
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.
LGTM and tests well. Thanks for the work @jayeshmangwani
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Cherry-picked to staging by @sketchydroide in version: 1.1.57-8 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by @chiragsalian in version: 1.1.57-17 🚀
|
Details
Fixed Issues
$ #7537
Tests
Test under storybook
npm run storybook
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
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)PR Reviewer Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followed/** comment above it */
displayName
propertythis
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)QA Steps
Screenshots
Web
After-7537.mov
Mobile Web
mWeb.mov
Desktop
8758-Desktop.mov
iOS
8758-iOs.mov
Android
8758-Android.mp4
I have read the CLA Document and I hereby sign the CLA