-
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
fix: constrain min and max age date for dob pickers #17072
fix: constrain min and max age date for dob pickers #17072
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@@ -18,11 +18,16 @@ const propTypes = { | |||
* `onInputChange` would always be called with a Date (or null) | |||
*/ | |||
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |||
|
|||
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
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.
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |
/** A minimum date (oldest) allowed to select */ | |
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
@@ -18,11 +18,16 @@ const propTypes = { | |||
* `onInputChange` would always be called with a Date (or null) | |||
*/ | |||
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |||
|
|||
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |||
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
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.
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |
/** A maximum date (earliest) allowed to select */ | |
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
@@ -18,6 +18,9 @@ class DatePicker extends React.Component { | |||
|
|||
this.showPicker = this.showPicker.bind(this); | |||
this.setDate = this.setDate.bind(this); | |||
|
|||
this.maxDate = this.props.maxDate || new Date(CONST.DATE.MAX_DATE); |
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.
Too many repetition, lets move new new Date(CONST.DATE.MAX_DATE)
and new Date(CONST.DATE.MIN_DATE)
to default props
@@ -18,11 +18,16 @@ const propTypes = { | |||
* `onInputChange` would always be called with a Date (or null) | |||
*/ | |||
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |||
|
|||
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
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 suggest unifying the types to a single type, Date instead of a Date or a string
@thienlnam 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] |
I'm not sure why it doesn't request review from assigned CME or C+ on the issue |
@Santhosh-Sellavel Because you need to mention them in the first (comment) line of the PR template. And it works only once on PR creation. |
Oh yes seems @koko57 missed including issue link while creating PR |
@Santhosh-Sellavel automatic reviewers assignment works based on first line of PR only, and not on linked issue. |
Sorry, that's not the case, it happens from issue linking only where details of CME & C+ are taken and requests review from them check at old PRs. We had to do it right the first time while submitting it's ready for review or it messes up. |
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.
Adding myself as reviewer
Well, then I'm not shure how it works. In this PR there was a correctly linked issue, but I've accidently moved mentioned reviewers on the second line so PullerBear hadn't assigned anyone. |
But I'm sure about how this work, that's why have the following as the first checklist item. I linked the correct issue in the ### Fixed Issues section above |
Adding @deetergp to this since this is from the issue he is CME on |
this.inputRef.setAttribute('max', moment(this.props.maxDate).format(CONST.DATE.MOMENT_FORMAT_STRING)); | ||
this.inputRef.setAttribute('min', moment(this.props.minDate).format(CONST.DATE.MOMENT_FORMAT_STRING)); |
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.
Why do we need to format it 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.
For min and max attribute input type="date" accepts a formatted string (yyyy-mm-dd). We pass the prop in Date format, so it needs to be formatted to work properly. We do the same for the value and the 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.
Looking good, @Santhosh-Sellavel will you be able to run through the testing and checklist?
Ah missed this one, will get it done today. |
Reviewer Checklist
Screenshots/VideosWeb & DesktopScreen.Recording.2023-04-13.at.12.04.22.AM.movMobile Web - ChromeScreen_Recording_20230413_002721_Chrome.mp4Mobile Web - SafariN/A as it fails we already know iOSSimulator.Screen.Recording.-.iPhone.14.-.2023-04-13.at.00.35.11.mp4AndroidScreen_Recording_20230413_002531_New.Expensify.mp4 |
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.
Mostly looks and tests wells!
this.minDate = moment().subtract(CONST.DATE_BIRTH.MAX_AGE, 'Y').toDate(); | ||
this.maxDate = moment().subtract(CONST.DATE_BIRTH.MIN_AGE_FOR_PAYMENT, 'Y').toDate(); |
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.
NAB, since they're one-liners and I'm not going to lose sleep over it. But since you bring it up, maybe it makes more sense to put the logic in the DatePicker component since both pages use it.
this.minDate = moment().subtract(CONST.DATE_BIRTH.MAX_AGE, 'Y').toDate(); | ||
this.maxDate = moment().subtract(CONST.DATE_BIRTH.MIN_AGE_FOR_PAYMENT, 'Y').toDate(); |
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.
NAB, since they're one-liners and I'm not going to lose sleep over it. But since you bring it up, maybe it makes more sense to put the logic in the DatePicker component since both pages use it.
Cool @deetergp Since we are going to remove old DatePicker soon, Lets merge this one. |
✋ 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/deetergp in version: 1.3.0-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.0-2 🚀
|
Details
Fixed Issues
$ #16691
PROPOSAL: #16691(COMMENT) - alternative solution
Tests
--- AdditionalDetailsStep
Offline tests
QA Steps
--- AdditionalDetailsStep
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)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)/** comment above it */
this
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)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
Web
Mobile Web - Chrome
Mobile Web - Safari
#16691 (comment)
Desktop
iOS
Android