-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Don't hide picker on esc key press or tap outside #16941
Conversation
@MonilBhavsar 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] |
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, thanks for the changes, agree with the suggestion from @s77rt
@hayata-suenaga wanted to note to make sure you link the issues correctly, it should just be a dollar sign followed by the actual github link which will allow for our automation for reviewers and deploy to work.
Also one more suggestion, can you please always try to add some info to the details section? I know it might be repeating whats in the issue but its great to have some context there on a first line "doing this because we decided that this is better than that"
Thank you very much 🙇
@mountiny updated the OP. thank you for the advice 🙇🏻♂️ |
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.
@s77rt or @rushatgabhane who has time to run through the checklist?
@rushatgabhane Was auto-assigned here #16422 but will take this PR if @rushatgabhane didn't. |
this.showPicker(); | ||
this.textInputRef.focus(); |
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.
Since we both show the picker and focus the input on component mount. Shouldn't we do the same on DOB? As suggested here #16779 (comment) just for consistency. (whenever the calendar is shown, the input is also focused)
I think this will be updated that we wont close the picker after selection so hold on testing @s77rt thanks! |
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.
@hayata-suenaga I think we need to update the test a little bit, it says the picker should be closed when user selects the date, but we concluded it should never close.
cc @s77rt are you able to run tests on this, the picker should basically never close.
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.
diff --git a/src/components/NewDatePicker/datePickerPropTypes.js b/src/components/NewDatePicker/datePickerPropTypes.js
index 0c3906e3c6..514a77a6c2 100644
--- a/src/components/NewDatePicker/datePickerPropTypes.js
+++ b/src/components/NewDatePicker/datePickerPropTypes.js
@@ -29,9 +29,6 @@ const propTypes = {
/** Default year to be set in the calendar picker */
selectedYear: PropTypes.string,
-
- /** A function called when picked is closed */
- onHidePicker: PropTypes.func,
};
const defaultProps = {
@@ -39,7 +36,6 @@ const defaultProps = {
minDate: moment().year(CONST.CALENDAR_PICKER.MIN_YEAR).toDate(),
maxDate: moment().year(CONST.CALENDAR_PICKER.MAX_YEAR).toDate(),
value: undefined,
- onHidePicker: () => {},
};
export {propTypes, defaultProps};
diff --git a/src/components/NewDatePicker/index.js b/src/components/NewDatePicker/index.js
index e117eaf9f2..77f061d95b 100644
--- a/src/components/NewDatePicker/index.js
+++ b/src/components/NewDatePicker/index.js
@@ -47,14 +47,6 @@ class NewDatePicker extends React.Component {
return;
}
this.showPicker();
- this.textInputRef.focus();
- }
-
- componentWillUnmount() {
- if (!this.unsubscribeEscapeKey) {
- return;
- }
- this.unsubscribeEscapeKey();
}
/**
@@ -73,7 +65,6 @@ class NewDatePicker extends React.Component {
setDate(selectedDate) {
this.setState({selectedDate}, () => {
this.props.onInputChange(moment(selectedDate).format(CONST.DATE.MOMENT_FORMAT_STRING));
- this.textInputRef.blur();
});
}
@@ -96,7 +87,6 @@ class NewDatePicker extends React.Component {
<View style={[this.props.isSmallScreenWidth ? styles.flex2 : {}]}>
<TextInput
forceActiveLabel
- ref={el => this.textInputRef = el}
icon={Expensicons.Calendar}
onPress={this.showPicker}
label={this.props.label}
@@ -112,13 +102,7 @@ class NewDatePicker extends React.Component {
</View>
{
this.state.isPickerVisible && (
- <Animated.View
- onMouseDown={(e) => {
- // To prevent focus stealing
- e.preventDefault();
- }}
- style={[styles.datePickerPopover, styles.border, {opacity: this.opacity}]}
- >
+ <Animated.View style={[styles.datePickerPopover, styles.border, {opacity: this.opacity}]}>
<CalendarPicker
minDate={this.props.minDate}
maxDate={this.props.maxDate}
diff --git a/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js b/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
index 4983c2cc5f..3174c8d6e9 100644
--- a/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
+++ b/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
@@ -39,7 +39,6 @@ class DateOfBirthPage extends Component {
this.validate = this.validate.bind(this);
this.updateDateOfBirth = this.updateDateOfBirth.bind(this);
- this.clearSelectedYear = this.clearSelectedYear.bind(this);
this.getYearFromRouteParams = this.getYearFromRouteParams.bind(this);
this.minDate = moment().subtract(CONST.DATE_BIRTH.MAX_AGE, 'Y').toDate();
this.maxDate = moment().subtract(CONST.DATE_BIRTH.MIN_AGE, 'Y').toDate();
@@ -65,9 +64,6 @@ class DateOfBirthPage extends Component {
const {params} = this.props.route;
if (params && params.year) {
this.setState({selectedYear: params.year});
- if (this.datePicker) {
- this.datePicker.showPicker();
- }
}
}
@@ -82,13 +78,6 @@ class DateOfBirthPage extends Component {
);
}
- /**
- * A function to clear selected year
- */
- clearSelectedYear() {
- this.setState({selectedYear: ''});
- }
-
/**
* @param {Object} values
* @param {String} values.dob - date of birth
@@ -131,14 +120,12 @@ class DateOfBirthPage extends Component {
>
<NewDatePicker
autoFocus
- ref={ref => this.datePicker = ref}
inputID="dob"
label={this.props.translate('common.date')}
defaultValue={privateDetails.dob || ''}
minDate={this.minDate}
maxDate={this.maxDate}
selectedYear={this.state.selectedYear}
- onHidePicker={this.clearSelectedYear}
/>
</Form>
</ScreenWrapper>
NewDatePicker
onHidePicker
callback is no longer needed: calendar won't hide.textInputRef
is no longer needed: we no longer need to focus/blur that was used in combination with hiding the calendar.unsubscribeEscapeKey
is never set since we won't hide the calendar on ESC.Animated.View
no longer need to handle theonMouseDown
, this was only used for focus management (prevent focus stealing).
DateOfBirthPage
clearSelectedYear
is redundant as we removed theonHidePicker
callback.datePicker.showPicker()
is redundant, the picker is already shown since we didn't hide it in the first place.
Sorry I had to include this in one diff. I can't suggest changes on code beyond the PR.
I updated the test steps @s77rt thank you for the astute PR review. I pushed the new commit. |
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.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.
LGTM! 🚀
thanks for the review @s77rt, i won't be reviewing this because of ⌚ 😢 |
Edit: nvm, i read the slack convo |
sorry @s77rt i realized you already approved this PR |
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.
No problem @hayata-suenaga. Approving again 😁
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 @hayata-suenaga and @s77rt!
✋ 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.2.99-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.2.99-6 🚀
|
Details
As per this slack convo, we decided to not to hide the calendar when the click event happens outside or the ESC key is pressed. With this PR, the calendar doesn't hide itself anymore on web (on mobile native platforms, the calendar already doesn't hide when tapped outside.).
Fixed Issues
$ #16422
Tests / QA Steps
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
chrome.mov
safari.mov
Mobile Web - Chrome
mobile.chrome.mov
Mobile Web - Safari
mobile.safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov