-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fixed Checkbox and password cursor state while hiding/showing #13317
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@Julesssss @eVoloshchak One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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'm seeing this error on pages with input/checkboxes. Not entirely sure it's caused by this PR, but has anyone else noticed it?
Strange. I never saw such error before. Doesn't seem like any property that I have changed.. |
Yep, just confirmed that it's occurring on main too 👍 |
Oh nice! So, does this pass all the tests then? |
I need to review the new changes still, and will do after @eVoloshchak has had a chance to review. |
src/components/Checkbox/index.js
Outdated
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
onMouseDown={props.onMouseDown ? props.onMouseDown : props.onPress} | ||
onPress={undefined} |
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.
onPress={undefined} |
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.
Actually this is important to set it as undefined because not doing so makes this event fire twice. That was the reason it was causing a regression earlier.
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.
Actually this is important to set it as undefined because not doing so makes this event fire twice. That was the reason it was causing a regression earlier.
Oh, I see, thanks for pointing that out, I didn't realize it was passed with the ...props
. I think we can use _.omit
to make it more readable
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
onPress={props.onPress ? props.onPress : props.onMouseDown} | ||
onMouseDown={undefined} |
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.
Wouldn't this break with a mouse connected to an android phone/tablet?
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 don't think so because the mouse click must also fire the onPress event as it does on the web version as well. On web, when the mouse is clicked, both onPress and onMouseDown as fired, so I wouldn't expect any reason for a different behaviour with a mouse connected to android..
src/components/Checkbox/index.js
Outdated
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
onMouseDown={props.onMouseDown ? props.onMouseDown : props.onPress} | ||
onPress={undefined} |
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.
Actually this is important to set it as undefined because not doing so makes this event fire twice. That was the reason it was causing a regression earlier.
Oh, I see, thanks for pointing that out, I didn't realize it was passed with the ...props
. I think we can use _.omit
to make it more readable
src/components/Checkbox/index.js
Outdated
const Checkbox = props => ( | ||
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} |
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.
{...props} | |
{..._.omit(props, 'onPress')} |
const Checkbox = props => ( | ||
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} |
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.
{...props} | |
{..._.omit(props, 'onMouseDown')} |
src/components/Checkbox/index.js
Outdated
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
onMouseDown={props.onMouseDown ? props.onMouseDown : props.onPress} |
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.
onMouseDown={props.onMouseDown ? props.onMouseDown : props.onPress} | |
onMouseDown={props.onMouseDown || props.onPress} |
I might be wrong but this should be equivalent, for .native
file too
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.
Let me just try to apply all these changes and test once
Implemented all the requested changes in this commit |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2022-12-07.at.21.52.03.movMobile Web - ChromeScreen_Recording_20221207-221022_Chrome.mp4Mobile Web - SafariScreen.Recording.2022-12-07.at.21.53.33.movDesktopScreen.Recording.2022-12-07.at.22.14.42.moviOSScreen.Recording.2022-12-07.at.22.12.47.movAndroidScreen_Recording_20221207-221151_New.Expensify.mp4 |
|
Hey @someone-here, I'll do the final review once the conflicts are resolved, then we can merge 🤞 |
I synced my fork main branch with the expensify main then merged it into the current bugfix branch and resolved all the conflicts. I hope this eliminates all the conflicts. |
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, 'onMouseDown')} | ||
onPress={props.onPress || props.onMouseDown} |
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.
Sorry to not mention this before, but I wonder why onMouseDown is necessary in the native Component? Perhaps a comment would help clear up why we need both to anyone looking at this in the future.
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.
// If no onPress is passed, then execute the onMouseDown function
Is this comment ok?
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.
Should I add a commit with this 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.
It just doesn't make much sense to me why native components would ever need onMouseDown
. Couldn't it be removed entirely?
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.
It is actually essential. You see what I'm doing here is not executing any code on the onMouseDown
event, but if the onMouseDown
prop is passed, then I am executing the prop passed on the onPress
event because the onMouseDown
doesn't fire in native.
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.
That makes sense to me for the general component, but there will never be an onMouseDown event for the native component, right? Or am I missunderstanding
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.
Yes there will never be an onMouseDown According to my knowledge. You are you proposing to remove the omit from the props spread? I had just added it to eliminate any chance of double event firing in any edge case or such... At first I thought you were referring to the onPress={props.onPress || props.onMouseDown}
, that line is essential but the omit
is not essential, it just to make sure no edge cases or double event firing happens...
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.
At first I thought you were referring to the onPress={props.onPress || props.onMouseDown}, that line is essential
Oh yeah, sorry that is what I meant. It would be great to add a comment that explains why this is necessary --- to help people like me who are a bit confused by seeing it there.
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.
Every checkbox can have two click handlers onPress
and onMouseDown
. As there is no onMouseDown
event on native, any prop that is passed to be executed on the onMouseDown
event should be executed on the onPress
event instead.
Should I add this as a multiline comment above that line?
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.
Hey @someone-here. This has made me realise that the solution is just a bit too complex for solving a small issue. Let's drop this one and move onto other bugs 👍
I'm having second thoughts about this PR now as it's adding quite a bit of complexity to resolve a simple issue that could actually be considered expected native behavior. I worry that this makes the Checkbox component unnecessarily tied up with the callbacks. We'll still pay out, but I'm going to just close this PR and close the issue. |
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.
Closed as explained here.
Okay, I guess.... So what will be my next course of action? |
Nothing left to do here. We'll pay out as usual. |
@Julesssss
@eVoloshchak
Details
Fixed the regression
Fixed Issues
$ #12018
$ #12018 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesWaiting 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)Screenshots/Videos
Web
chrome-new.2.mov
Mobile Web - Chrome
mWeb-Chrome.mp4
Safari
safari.mov
Desktop
Desktop.mov
iOS
iOS.mov
Android
android-new.mov