-
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
fix console error TypeError can't read properties of null in Hoverable.js #19488
Conversation
…ontains') in Hoverable.js
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!
@@ -98,7 +98,7 @@ class Hoverable extends Component { | |||
onMouseEnter={() => this.setIsHovered(true)} | |||
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
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