refactor: forward ref to datepicker instance#16779
Conversation
|
I faced a ref forwarding issue, componentDidMount is called before the ref callback, so I wrapped it with setTimeout. |
|
@mountiny This PR is ready for review 🚀 |
|
I saw some places in the code base where |
|
I tried to fix it in many ways, but none of them helped. I'm guessing this problem with ref forwarding may be caused by HOC |
|
Yeah might be good to bring this to the open source channel and see if others have some ideas of why it does not work, at least we can confirm there is no other way |
|
Good point 👌 Let's see. I asked in opensource channel |
|
We can create a callback function from |
|
@ArekChr We can implement a new prop, such as this.state = {
isPickerVisible: props.autoFocus || false,
...
};
...
this.opacity = new Animated.Value(props.autoFocus ? 1 : 0);Screen.Recording.2023-03-31.at.4.58.21.PM.mov |
Reviewer Checklist
Screenshots/VideosWeb16779.Web.movMobile Web - Chrome16779.mWeb.Chrome.movMobile Web - Safari16779.mWeb.Safari.mp4Desktop16779.Desktop.moviOS16779.iOS.mp4Android16779.Android.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.2.94-0 🚀
|
| if (_.isFunction(this.datePicker.click)) { | ||
| this.datePicker.click(); | ||
| } | ||
| this.datePicker.showPicker(); |
There was a problem hiding this comment.
This introduced a regression https://expensify.slack.com/archives/C049HHMV9SM/p1680625096406979 The reason is that the text input is now no longer focused so no blur event will be emitted and the calendar will not hide on clicking outside. Fix:
diff --git a/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js b/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
index 4983c2cc5f..51d3dc5c55 100644
--- a/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
+++ b/src/pages/settings/Profile/PersonalDetails/DateOfBirthPage.js
@@ -67,6 +67,7 @@ class DateOfBirthPage extends Component {
this.setState({selectedYear: params.year});
if (this.datePicker) {
this.datePicker.showPicker();
+ this.datePicker.textInputRef.focus();
}
}
}There was a problem hiding this comment.
Discussing in slack I dont think this is a regression, we have a different issue.
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.94-3 🚀
|
Details
Fixed Issues
$ #16551
$ #16551 (comment)
Tests
Offline tests
No offline tests needed
QA Steps
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
web.mov
Mobile Web - Chrome
mWeb.Chrome.mov
Mobile Web - Safari
mWeb.Safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
Android.mov