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! |
| */ | ||
| defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | ||
|
|
||
| minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
There was a problem hiding this comment.
| minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |
| /** A minimum date (oldest) allowed to select */ | |
| minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
| 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.
| maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | |
| /** A maximum date (earliest) allowed to select */ | |
| maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
| 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.
Too many repetition, lets move new new Date(CONST.DATE.MAX_DATE) and new Date(CONST.DATE.MIN_DATE) to default props
| */ | ||
| defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), | ||
|
|
||
| minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]), |
There was a problem hiding this comment.
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. |
Santhosh-Sellavel
left a comment
There was a problem hiding this comment.
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.
Why do we need to format it here?
There was a problem hiding this comment.
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.
mountiny
left a comment
There was a problem hiding this comment.
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 |
Santhosh-Sellavel
left a comment
There was a problem hiding this comment.
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.
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.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
#16691 (comment)
Desktop
iOS
Android