-
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
refactor: forward ref to datepicker instance #16779
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. |
e60e8dd
to
4cdc921
Compare
@mountiny This PR is ready for review 🚀 |
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 am not sure why this is happening, but can you try to think of other way to solve this without using setTimeout, those are usually very hacky solutions we try to avoid almost at all cost.
cc @mollfpr what do you think?
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 |
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 👍
All yours @mountiny!
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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
web.mov
Mobile Web - Chrome
mWeb.Chrome.mov
Mobile Web - Safari
mWeb.Safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
Android.mov