Fixed Checkbox and password cursor state while hiding/showing#13317
Fixed Checkbox and password cursor state while hiding/showing#13317esh-g wants to merge 4 commits intoExpensify:mainfrom
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] |
Julesssss
left a comment
There was a problem hiding this comment.
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.
| onPress={undefined} |
There was a problem hiding this comment.
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.
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.
Wouldn't this break with a mouse connected to an android phone/tablet?
There was a problem hiding this comment.
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.
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.
| {...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.
| {...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.
| 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.
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.
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.
// If no onPress is passed, then execute the onMouseDown function
Is this comment ok?
There was a problem hiding this comment.
Should I add a commit with this comment?
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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. |
|
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesWaiting 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)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