-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Refactor new date picker #21792
Refactor new date picker #21792
Conversation
…n, poc for year picker modal
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.
Just nitpicks
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
src/components/NewDatePicker/CalendarPicker/ScreenSlideAnimation.js
Outdated
Show resolved
Hide resolved
Hey there @ArekChr , We have some bugs :
Screen.Recording.2023-07-03.at.2.45.41.PM.mov
Screen.Recording.2023-07-03.at.11.59.24.AM.movScreen.Recording.2023-07-03.at.11.59.54.AM.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.
@ArekChr I believe we implemented something different for a similar case , specifically the AvatarCropModal , we utilized the modal to display a new screen. It appears that the modal possesses the necessary animations and props to handle this scenario as well. I'm uncertain about the optimal approach we should adopt, but for the sake of consistency, I think it's best to adhere to a single approach.
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.
Great idea! What you proposed works flawlessly, with the only difference being that the modal has a backdrop, that the YearPickerPage did not have previously. But this matches the AvatarCropModal and brings more design consistency, so I think it's a even bigger win
Screen.Recording.2023-07-06.at.14.53.57.mov
thanks for the reviews and testing so far. great job, lets egt this done on Monday 🎉 |
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.
Looks we are very close, left few comments.
import {radioListItemPropTypes} from '../../SelectionListRadio/selectionListRadioPropTypes'; | ||
|
||
const propTypes = { | ||
...withLocalizePropTypes, |
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.
...withLocalizePropTypes, |
Since this is a functional component we should use localize hook :
const {translate} = useLocalize();
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 wasn't aware, thanks for this!
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
...withCurrentUserPersonalDetailsPropTypes, |
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.
...withCurrentUserPersonalDetailsPropTypes, |
Not needed.
}; | ||
|
||
function YearPickerModal(props) { | ||
const headerMessage = props.textInputValue.trim() && !props.years.length ? props.translate('common.noResultsFound') : ''; |
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 handle the search (filtering) inside this component something similar to :
const [searchText, setSearchText] = useState('');
const {sections, headerMessage} = useMemo(
() => {
const yearsList = searchText === '' ? props.years : _.filter(props.years, (year) => year.text.includes(searchText));
return {
headerMessage: !yearsList.length ? translate('common.noResultsFound') : '',
sections: [{data: yearsList, indexOffset: 0}],
}
},
[props.years, searchText],
)
This will avoids unnecessary renders of calendar when we filter the list. It will also resets the search and fix this bug :
Screen.Recording.2023-07-09.at.8.34.52.PM.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.
Cool, I like this approach. But that does not reset the search alone, because the modal is never unmounted, it just becomes invisible. So I also added an effect to clear the search text when it closes
textInputValue: '', | ||
yearsFiltered: this.years, |
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.
As suggested , let's move filtering logic to YearPickerModal
.
}; | ||
|
||
this.filterYears = this.filterYears.bind(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.
this.filterYears = this.filterYears.bind(this); |
Same
@@ -305,12 +243,21 @@ class CalendarPicker extends React.PureComponent { | |||
})} | |||
</View> | |||
))} | |||
<YearPickerModal | |||
isVisible={this.state.isYearPickerVisible} | |||
years={this.state.yearsFiltered} |
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.
years={this.state.yearsFiltered} | |
years={this.years} |
we only need to pass initial years array.
textInputValue={this.state.textInputValue} | ||
onChangeText={this.filterYears} |
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.
textInputValue={this.state.textInputValue} | |
onChangeText={this.filterYears} |
As suggested , Not needed.
}; | ||
|
||
const defaultProps = { | ||
...withCurrentUserPersonalDetailsDefaultProps, |
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.
...withCurrentUserPersonalDetailsDefaultProps, |
unused.
@@ -0,0 +1,84 @@ | |||
import React from 'react'; | |||
import PropTypes from 'prop-types'; | |||
import {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../../withCurrentUserPersonalDetails'; |
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.
import {withCurrentUserPersonalDetailsDefaultProps, withCurrentUserPersonalDetailsPropTypes} from '../../withCurrentUserPersonalDetails'; |
unused.
@fedirjh Sent fixes to all your latest comments! :) |
I see that some unit tests failed and I'm working on it 👍🏻 |
Fixed 👌🏻 |
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.
Code looks good to me. Left one small comment.
textInputLabel={translate('yearPickerPage.selectYear')} | ||
textInputValue={searchText} | ||
textInputMaxLength={4} | ||
onChangeText={setSearchText} |
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.
onChangeText={setSearchText} | |
onChangeText={(text) => setSearchText(text.replace(CONST.REGEX.NON_NUMERIC, '').trim())} |
This will prevent searching for non num characters
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.
Nice, done
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-07-10.at.3.34.56.PM.movMobile Web - ChromeScreen.Recording.2023-07-10.at.3.33.59.PM.movMobile Web - SafariScreen.Recording.2023-07-10.at.3.09.31.PM.movDesktopDesktop.moviOSScreen.Recording.2023-07-10.at.2.24.08.PM.movAndroidScreen.Recording.2023-07-10.at.3.32.34.PM.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.
Looks good to me.
@fedirjh Great job on the review and thanks @thiagobrez for acting fast! |
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 everyone, great job on 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/mountiny in version: 1.3.39-0 🚀
|
Awesome work! Love the simplification. |
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.39-11 🚀
|
Coming from #19073: This refactor (page > modal) caused modal overlay regression again which was fixed during navigation refactor, though it's minor UI inconsistency. |
this.props.onSelected(this.getSelectedDateString()); | ||
}, | ||
); | ||
this.setState((prev) => ({currentDateView: moment(prev.currentDateView).subtract(1, 'months').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.
✋ Coming from #33006
The refactor for moveToPrevMonth
and moveToNextMonth
doesn't update the year.
<Modal | ||
type={CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED} | ||
isVisible={props.isVisible} | ||
onClose={props.onClose} |
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 should include shouldHandleNavigationBack
props to handle physical back button on mWeb. More details in:
#52383 (comment)
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.
@hungvu193 shouldHandleNavigationBack
was not present when this PR was implemented. It was added in #38693.
Details
This pull request introduces significant improvements to the Date Picker component by refactoring the codebase and implementing logic changes. The main objectives are to enhance reusability by removing navigation.
Fixed Issues
$ #20630
PROPOSAL: #20630 (comment)
Tests
Offline tests
No offline tests needed.
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
web.mov
Mobile Web - Chrome
mobile.chrome.mov
Mobile Web - Safari
mobile.safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov