Hoverable component refactored from class into functional approach#27223
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
src/components/Hoverable/index.js
Outdated
There was a problem hiding this comment.
Not seeing that you are exporting the Hoverable component
src/components/Hoverable/index.js
Outdated
There was a problem hiding this comment.
Add a displayName field
Hoverable.displayName = 'Hoverable';
There was a problem hiding this comment.
AFAIK, there is no need to set displayName explicitly on components. Should we propose an update to the style doc you've mentioned? Thanks for noticing that!
There was a problem hiding this comment.
Yeah, but this standard is from Expensify codebase
There was a problem hiding this comment.
Sure, let's keep it this way then :)
src/components/Hoverable/index.js
Outdated
There was a problem hiding this comment.
I think here is missing the check if (disabled) { return; } before doing any onHoverXXX
There was a problem hiding this comment.
That's a great point! I think we can discuss how flow with disabled could look like, as it is now conflicting with internal isHovered state declaration (for example we are not prohibiting event handlers to be executed even if disabled is set to true)
src/components/Hoverable/index.js
Outdated
There was a problem hiding this comment.
@gedu, should we list dependency as child or child.props.onBlur ?
|
@kacper-mikolajczak check and thick all boxes and add screenshots/videos for all platforms. |
src/components/Hoverable/index.js
Outdated
There was a problem hiding this comment.
@kacper-mikolajczak It seems this listener has been not migrated, checkHover is not needed anymore?
There was a problem hiding this comment.
Great catch, thanks! Done ✅
ArekChr
left a comment
There was a problem hiding this comment.
@kacper-mikolajczak Overall, the code changes look good. I left some minor comments. Please also complete the checklist. Thanks!
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemweb.chrome.movMobile Web - Safarimweb.safari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
ArekChr
left a comment
There was a problem hiding this comment.
All good, thanks for PR!
|
LGTM! |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #16161 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
|
Hey folks, I will give a review today 🤞 |
hurali97
left a comment
There was a problem hiding this comment.
@kacper-mikolajczak Looks good, nice work 🎉 I have a single comment and would be cool if you can get that in or discuss 👍 I tested with updated changes and it works well too.
The reason I brought this change is in react-devtools you'll see the Hoverable being rendered twice because of isScrolling and isHovered.
src/components/Hoverable/index.js
Outdated
| this.checkHover = this.checkHover.bind(this); | ||
| function InnerHoverable({disabled, onHoverIn, onHoverOut, children, shouldHandleScroll}, outerRef) { | ||
| const [isHovered, setIsHovered] = useState(false); | ||
| const [isScrolling, setIsScrolling] = useState(false); |
There was a problem hiding this comment.
Got you @hurali97! I've implemented suggested changes 👍 Let's review it once again and we are good to go :)
Beamanator
left a comment
There was a problem hiding this comment.
Can we just add a comment here since useImperativeHandle isn't super well known AFAIK?
Then we can LGTM!
|
Seems jest unit test2 is failing, i'll retry and see if it passes |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Regression from this PR: Composer action menu, emoji pickers are broken Screen.Recording.2023-10-02.at.7.09.24.PM.mov |
|
Regression: This PR seem to have introduced a critical bug where App crashes on pressing back button. @kacper-mikolajczak @ArekChr @Beamanator https://expensify.slack.com/archives/C049HHMV9SM/p1696231998119979 |
|
Created the GH ticket #28634 |
|
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.76-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.76-6 🚀
|
|
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.77-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.77-7 🚀
|

Details
In this PR
Hoverablecomponent was re-written from class to functional approach.Fixed Issues
$ #16161
PROPOSAL: #16161 (comment)
Tests
For platforms with hover:
For platforms without hover:
Offline tests
QA Steps
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.Screenshots/Videos
Web
Hoverable_web.mov
Mobile Web - Chrome
Hoverable_web_android.mov
Mobile Web - Safari
Hoverable_web_ios.mov
Desktop
Hoverable_desktop.mov
iOS
Hoverable_ios.mov
Android
Hoverable_android.mov