Reopened/Feature: Remove moment from datepicker#29984
Reopened/Feature: Remove moment from datepicker#29984mountiny merged 6 commits intoExpensify:mainfrom
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@allroundexperts 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] |
|
@allroundexperts could you please tests especially the cases which were caught in staging before? |
|
@waterim Conflicts. |
|
@allroundexperts resolved! |
|
@allroundexperts bump for a checklist, thanks! |
|
Conflicts again. |
|
@allroundexperts |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-10-13.at.2.40.48.AM.movMobile Web - ChromeScreen.Recording.2023-10-13.at.2.46.48.AM.movMobile Web - SafariScreen.Recording.2023-10-13.at.2.44.49.AM.movDesktopScreen.Recording.2023-10-13.at.2.52.13.AM.moviOSScreen.Recording.2023-10-13.at.2.45.34.AM.movAndroidScreen.Recording.2023-10-13.at.2.47.55.AM.mov |
allroundexperts
left a comment
There was a problem hiding this comment.
Working well!
Screen.Recording.2023-10-31.at.11.34.07.AM.mov
|
✋ 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/mountiny in version: 1.3.95-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.95-9 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.96-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
| const hasAvailableDatesNextMonth = startOfDay(endOfMonth(new Date(this.props.maxDate))) > addMonths(new Date(this.state.currentDateView), 1); | ||
| const hasAvailableDatesPrevMonth = startOfDay(new Date(this.props.minDate)) < endOfMonth(subMonths(new Date(this.state.currentDateView), 1)); |
There was a problem hiding this comment.
We should have the same logic here. This caused a regression #31793
| const isAfterMaxDate = currentDate > startOfDay(new Date(this.props.maxDate)); | ||
| const isDisabled = !day || isBeforeMinDate || isAfterMaxDate; | ||
| const isSelected = moment(this.props.value).isSame(moment([currentYearView, currentMonthView, day]), 'day'); | ||
| const isSelected = isSameDay(new Date(this.props.value), new Date(currentYearView, currentMonthView, day)); |
There was a problem hiding this comment.
In moment if we pass a null day we will get an invalid date but this is not the case with Date. This lead to a regression #31793.
moment([2000, 1, null]).format() // 'Invalid date'
new Date(2000, 1, null) // Mon Jan 31 2000 00:00:00 GMT+0100 (Central European Standard Time)| } | ||
|
|
||
| let currentDateView = moment(props.value, CONST.DATE.MOMENT_FORMAT_STRING).toDate(); | ||
| let currentDateView = new Date(props.value); |
There was a problem hiding this comment.
There was another instance of date being fetched incorrectly on this line.
When props.value type is 'YYYY-MM-DD' and user timezone is behind UTC, the previous date is returned.
parseISO should have been used like others.
Details
This PR is to remove moment from Datepicker
Fixed Issues
$ #19810
Tests
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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.