-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix console error TypeError can't read properties of null in Hoverable.js #19488
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
Conversation
…ontains') in Hoverable.js
dangrous
left a 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.
LGTM!
| onMouseLeave={() => this.setIsHovered(false)} | ||
| onBlur={(el) => { | ||
| if (this.wrapperView.contains(el.relatedTarget)) { | ||
| if (!_.isNull(this.wrapperView) && this.wrapperView.contains(el.relatedTarget)) { |
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.
@ahmedGaber93 Should we do this in other onBlur too?
App/src/components/Hoverable/index.js
Lines 83 to 86 in 8f9d1c5
| onBlur: (el) => { | |
| if (!this.wrapperView.contains(el.relatedTarget)) { | |
| this.setIsHovered(false); | |
| } |
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.
@mollfpr yes, we should.
I think we need to check null here also to prevent this error in all places
if (!_.isNull(this.wrapperView) && !this.wrapperView.contains(el.relatedTarget))
do you agree?
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.
@ahmedGaber93 Sounds good to me!
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.
@ahmedGaber93 On second thought, looking and the original condition !this.wrapperView.contains(el.relatedTarget), so that's mean null this.wrapperView is also true?
I'm not sure to understand the condition; it's either
!_.isNull(this.wrapperView) && !this.wrapperView.contains(el.relatedTarget)_.isNull(this.wrapperView) || !this.wrapperView.contains(el.relatedTarget)
What do you guys think?
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.
@mollfpr I think the two conditions will prevent call contains from null this.wrapperView.
But even though we don't have any UI visual issues, I think the second condition logic is better because it will set isHovered to fallback false.
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.
@ahmedGaber93 Let's go with the second logic then! Sorry for the hustle 🙏
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.
@mollfpr are you mean use !_.isNull(this.wrapperView) && in the two places
or remove it from the second place here.
App/src/components/Hoverable/index.js
Lines 83 to 86 in 8f9d1c5
| onBlur: (el) => { | |
| if (!this.wrapperView.contains(el.relatedTarget)) { | |
| this.setIsHovered(false); | |
| } |
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.
@ahmedGaber93 Only for remove it from this.
if (!this.wrapperView.contains(el.relatedTarget)) {
this.setIsHovered(false);
}
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.
@mollfpr removed, you can review now.
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.
Is there any problem if just adding this?
- if (this.wrapperView.contains(el.relatedTarget)) {
+ if (this.wrapperView && this.wrapperView.contains(el.relatedTarget)) {
Reviewer Checklist
Screenshots/VideosWeb19488.Web.movMobile Web - Chrome19488.mWeb.Chrome.mp4Mobile Web - Safari19488.mWeb.Safari.mp4Desktop19488.Desktop.moviOS19488.iOS.mp4Android19488.Android.mp4 |
|
@ahmedGaber93 Could you resolve the conflict? Thanks! |
|
We can close this right? |
Details
Fixed Issues
$ #19228
$ #19228 (comment)
Tests
Offline tests
N/A.
QA Steps
Same as Tests step.
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
Screen.Recording.2023-05-23.at.9.20.46.PM.mov
Mobile Web - Chrome
Screen.Recording.2023-05-23.at.10.06.45.PM.mov
Mobile Web - Safari
Screen.Recording.2023-05-23.at.10.18.52.PM.mov
Desktop
Screen.Recording.2023-05-23.at.10.22.30.PM.mov
iOS
Screen.Recording.2023-05-23.at.10.20.52.PM.mov
Android
Screen.Recording.2023-05-23.at.9.24.22.PM.mov