-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Keep input cursor in place when toggling password checkbox #13187
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
Changes from all commits
fe8e232
29c66cb
96c6f0f
3146d1d
d97a350
209a08d
ce2ca75
295f5d2
d3c5858
08c2282
08a3600
726708d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from 'react'; | ||
| import BaseCheckbox from './BaseCheckbox'; | ||
|
|
||
| const Checkbox = props => ( | ||
| <BaseCheckbox | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| onMouseDown={props.onMouseDown ? props.onMouseDown : props.onPress} | ||
| /> | ||
| ); | ||
|
|
||
| Checkbox.propTypes = BaseCheckbox.propTypes; | ||
| Checkbox.defaultProps = BaseCheckbox.defaultProps; | ||
| Checkbox.displayName = 'Checkbox'; | ||
|
|
||
| export default Checkbox; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from 'react'; | ||
| import BaseCheckbox from './BaseCheckbox'; | ||
|
|
||
| const Checkbox = props => ( | ||
| <BaseCheckbox | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| onPress={props.onPress ? props.onPress : props.onMouseDown} | ||
| /> | ||
| ); | ||
|
|
||
| Checkbox.propTypes = BaseCheckbox.propTypes; | ||
| Checkbox.defaultProps = BaseCheckbox.defaultProps; | ||
| Checkbox.displayName = 'Checkbox'; | ||
|
|
||
| export default Checkbox; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,7 +186,11 @@ class BaseTextInput extends Component { | |
| ]).start(); | ||
| } | ||
|
|
||
| togglePasswordVisibility() { | ||
| togglePasswordVisibility(event) { | ||
| if (!event) { | ||
| return; | ||
| } | ||
| event.preventDefault(); | ||
| this.setState(prevState => ({passwordHidden: !prevState.passwordHidden})); | ||
| } | ||
|
|
||
|
|
@@ -291,8 +295,7 @@ class BaseTextInput extends Component { | |
| {this.props.secureTextEntry && ( | ||
| <Checkbox | ||
| style={styles.secureInputShowPasswordButton} | ||
| onPress={this.togglePasswordVisibility} | ||
| onMouseDown={e => e.preventDefault()} | ||
| onMouseDown={this.togglePasswordVisibility} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can't be working since there is no Screen.Recording.2022-11-30.at.20.45.29.movIt just does nothing on native and mWeb
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the handler for native(checkbox.native.js), it automatically adds the onPress if it is not present. Or at least it used to.... |
||
| > | ||
| <Icon | ||
| src={this.state.passwordHidden ? Expensicons.Eye : Expensicons.EyeDisabled} | ||
|
|
||
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.
This should have been avoided. Please do not disable Linter warnings unless that is the only option.
e.g.
Here we have to disable the rule. because we want to pass all the generic/default props through.