-
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
Make login form accessible to Password Managers #5275
Merged
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
5b66bdc
make Input accessible
parasharrajat 8fcf1fd
fix: input for password Managers
parasharrajat 228b1b2
adjust the Form for Password Managers
parasharrajat 69f0e1d
Merge branch 'main' of github.com:Expensify/Expensify.cash into login…
parasharrajat 31f6ebb
Merge latest chagnes from master
parasharrajat 0c95acf
Refactor code
parasharrajat 08a441e
Refactor Form
parasharrajat f5c1709
last touch up
parasharrajat 28b22f1
Enable multi steo form
parasharrajat bf7859e
Multi step form support
parasharrajat b180d80
refactor page to set the focus correctly
parasharrajat 62683de
Pull latest changes
parasharrajat e5b81eb
fix: Dom change
parasharrajat 36ec46b
Pull latest changes
parasharrajat 9f035f1
refactor
parasharrajat e621911
Pull new changes from main
parasharrajat 14cb551
Merge branch 'main' of github.com:Expensify/Expensify.cash into login…
parasharrajat 5938bd8
Review- 1
parasharrajat c12aeab
Merge branch 'main' of github.com:Expensify/Expensify.cash into login…
parasharrajat 46430c7
Review comments
parasharrajat 8b3127a
fix: Collapsible view
parasharrajat d7365f0
fix: form
parasharrajat 9f5aa7b
pass down the name prop
parasharrajat 9703fe6
typos
parasharrajat a1c5ac0
Clear form
parasharrajat 530627f
Review -2
parasharrajat b594059
review-3
parasharrajat db6b4b6
Extra prop definition removed
parasharrajat 4da3cb1
Reafactor code to remove isvisible dependency in PasswordForm UI and …
parasharrajat d39fa49
fix prop definition
parasharrajat 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
53 changes: 33 additions & 20 deletions
53
src/components/ExpensiTextInput/ExpensiTextInputLabel/index.js
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 |
---|---|---|
@@ -1,26 +1,39 @@ | ||
import React, {memo} from 'react'; | ||
import React, {PureComponent} from 'react'; | ||
import {Animated} from 'react-native'; | ||
import styles from '../../../styles/styles'; | ||
import propTypes from './expensiTextInputLabelPropTypes'; | ||
import {propTypes, defaultProps} from './expensiTextInputLabelPropTypes'; | ||
|
||
const ExpensiTextInputLabel = props => ( | ||
<Animated.Text | ||
style={[ | ||
styles.expensiTextInputLabel, | ||
styles.expensiTextInputLabelDesktop, | ||
styles.expensiTextInputLabelTransformation( | ||
props.labelTranslateY, | ||
0, | ||
props.labelScale, | ||
), | ||
]} | ||
pointerEvents="none" | ||
> | ||
{props.label} | ||
</Animated.Text> | ||
); | ||
class ExpensiTextInputLabel extends PureComponent { | ||
componentDidMount() { | ||
if (!this.props.for) { | ||
return; | ||
} | ||
this.label.setNativeProps({for: this.props.for}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Animated.Text | ||
pointerEvents="none" | ||
accessibilityRole="label" | ||
ref={el => this.label = el} | ||
style={[ | ||
styles.expensiTextInputLabel, | ||
styles.expensiTextInputLabelDesktop, | ||
styles.expensiTextInputLabelTransformation( | ||
this.props.labelTranslateY, | ||
0, | ||
this.props.labelScale, | ||
), | ||
]} | ||
> | ||
{this.props.label} | ||
</Animated.Text> | ||
); | ||
} | ||
} | ||
|
||
ExpensiTextInputLabel.propTypes = propTypes; | ||
ExpensiTextInputLabel.displayName = 'ExpensiTextInputLabel'; | ||
ExpensiTextInputLabel.defaultProps = defaultProps; | ||
|
||
export default memo(ExpensiTextInputLabel); | ||
export default ExpensiTextInputLabel; |
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
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,16 @@ | ||
import React, {forwardRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import * as ComponentUtils from '../../libs/ComponentUtils'; | ||
|
||
const BaseForm = forwardRef((props, ref) => ( | ||
<View | ||
accessibilityRole={ComponentUtils.ACCESSIBILITY_ROLE_FORM} | ||
accessibilityAutoComplete="on" | ||
ref={ref} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
/> | ||
)); | ||
|
||
BaseForm.displayName = 'BaseForm'; | ||
export default BaseForm; |
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,28 @@ | ||
import React from 'react'; | ||
import BaseForm from './BaseForm'; | ||
|
||
class Form extends React.Component { | ||
componentDidMount() { | ||
if (!this.form) { | ||
return; | ||
} | ||
|
||
// Password Managers need these attributes to be able to identify the form elements properly. | ||
this.form.setNativeProps({ | ||
method: 'post', | ||
action: '/', | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<BaseForm | ||
ref={el => this.form = el} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default Form; |
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,8 @@ | ||
import React from 'react'; | ||
import BaseForm from './BaseForm'; | ||
|
||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
const Form = props => <BaseForm {...props} />; | ||
|
||
Form.displayName = 'Form'; | ||
export default Form; |
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,40 @@ | ||
import _ from 'underscore'; | ||
import React from 'react'; | ||
import {TextInput} from 'react-native'; | ||
import textInputWithNamepropTypes from './textInputWithNamepropTypes'; | ||
|
||
/** | ||
* On web we need to set the native attribute name for accessiblity. | ||
*/ | ||
class TextInputWithName extends React.Component { | ||
componentDidMount() { | ||
if (!this.textInput) { | ||
return; | ||
} | ||
if (_.isFunction(this.props.forwardedRef)) { | ||
this.props.forwardedRef(this.textInput); | ||
} | ||
|
||
if (this.props.name) { | ||
this.textInput.setNativeProps({name: this.props.name}); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<TextInput | ||
ref={el => this.textInput = el} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...this.props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
TextInputWithName.propTypes = textInputWithNamepropTypes.propTypes; | ||
TextInputWithName.defaultProps = textInputWithNamepropTypes.defaultProps; | ||
|
||
export default React.forwardRef((props, ref) => ( | ||
/* eslint-disable-next-line react/jsx-props-no-spreading */ | ||
<TextInputWithName {...props} forwardedRef={ref} /> | ||
)); |
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,20 @@ | ||
import React from 'react'; | ||
import {TextInput} from 'react-native'; | ||
import textInputWithNamepropTypes from './textInputWithNamepropTypes'; | ||
|
||
const TextInputWithName = props => ( | ||
<TextInput | ||
ref={props.forwardedRef} | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
/> | ||
); | ||
|
||
TextInputWithName.propTypes = textInputWithNamepropTypes.propTypes; | ||
TextInputWithName.defaultProps = textInputWithNamepropTypes.defaultProps; | ||
TextInputWithName.displayName = 'TextInputWithName'; | ||
|
||
export default React.forwardRef((props, ref) => ( | ||
/* eslint-disable-next-line react/jsx-props-no-spreading */ | ||
<TextInputWithName {...props} forwardedRef={ref} /> | ||
)); |
19 changes: 19 additions & 0 deletions
19
src/components/TextInputWithName/textInputWithNamepropTypes.js
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,19 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
/** Name attribute for the input */ | ||
name: PropTypes.string, | ||
|
||
/** A ref to forward to the text input */ | ||
forwardedRef: PropTypes.func, | ||
}; | ||
|
||
const defaultProps = { | ||
name: '', | ||
forwardedRef: () => {}, | ||
}; | ||
|
||
export default { | ||
propTypes, | ||
defaultProps, | ||
}; |
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,46 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../styles/styles'; | ||
import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
|
||
const toggleVisibilityViewPropTypes = { | ||
/** Whether the content is visible. */ | ||
isVisible: PropTypes.bool, | ||
}; | ||
|
||
export default function (WrappedComponent) { | ||
const WithToggleVisibilityView = props => ( | ||
<View style={!props.isVisible && styles.visuallyHidden}> | ||
<WrappedComponent | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={props.forwardedRef} | ||
isVisible={props.isVisible} | ||
/> | ||
</View> | ||
); | ||
|
||
WithToggleVisibilityView.displayName = `WithToggleVisibilityView(${getComponentDisplayName(WrappedComponent)})`; | ||
WithToggleVisibilityView.propTypes = { | ||
forwardedRef: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}), | ||
]), | ||
|
||
/** Whether the content is visible. */ | ||
isVisible: PropTypes.bool, | ||
}; | ||
WithToggleVisibilityView.defaultProps = { | ||
forwardedRef: undefined, | ||
isVisible: false, | ||
}; | ||
return React.forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<WithToggleVisibilityView {...props} forwardedRef={ref} /> | ||
)); | ||
} | ||
|
||
export { | ||
toggleVisibilityViewPropTypes, | ||
}; |
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,10 @@ | ||
/** | ||
* Web password field needs `current-password` as autocomplete type which is not supported on native | ||
*/ | ||
const PASSWORD_AUTOCOMPLETE_TYPE = 'current-password'; | ||
const ACCESSIBILITY_ROLE_FORM = 'form'; | ||
|
||
export { | ||
PASSWORD_AUTOCOMPLETE_TYPE, | ||
ACCESSIBILITY_ROLE_FORM, | ||
}; |
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,7 @@ | ||
const PASSWORD_AUTOCOMPLETE_TYPE = 'password'; | ||
const ACCESSIBILITY_ROLE_FORM = 'none'; | ||
|
||
export { | ||
PASSWORD_AUTOCOMPLETE_TYPE, | ||
ACCESSIBILITY_ROLE_FORM, | ||
}; |
Oops, something went wrong.
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.
ExpensiTextInputLabel.defaultProps =
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.
Yeah, Nice catch.
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.
Done.