-
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import _ from 'lodash'; | ||
import React from 'react'; | ||
import BaseCheckbox from './BaseCheckbox'; | ||
|
||
const Checkbox = props => ( | ||
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, 'onPress')} | ||
onMouseDown={props.onMouseDown || props.onPress} | ||
/> | ||
); | ||
|
||
Checkbox.propTypes = BaseCheckbox.propTypes; | ||
Checkbox.defaultProps = BaseCheckbox.defaultProps; | ||
Checkbox.displayName = 'Checkbox'; | ||
|
||
export default Checkbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import _ from 'lodash'; | ||
import React from 'react'; | ||
import BaseCheckbox from './BaseCheckbox'; | ||
|
||
const Checkbox = props => ( | ||
<BaseCheckbox | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, 'onMouseDown')} | ||
onPress={props.onPress || props.onMouseDown} | ||
/> | ||
); | ||
|
||
Checkbox.propTypes = BaseCheckbox.propTypes; | ||
Checkbox.defaultProps = BaseCheckbox.defaultProps; | ||
Checkbox.displayName = 'Checkbox'; | ||
|
||
export default Checkbox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theonMouseDown
prop is passed, then I am executing the prop passed on theonPress
event because theonMouseDown
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 theomit
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.
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
andonMouseDown
. As there is noonMouseDown
event on native, any prop that is passed to be executed on theonMouseDown
event should be executed on theonPress
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 👍