-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix form accessibility 2/4 #12370
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
Merged
luacmartins
merged 31 commits into
Expensify:main
from
mdneyazahmad:fix/7916-accessibility
Jan 25, 2023
Merged
Fix form accessibility 2/4 #12370
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
bc4fed4
Fix form submit with enter press
mdneyazahmad 94a6584
Fix submit with enter press on invite member page
mdneyazahmad 6c8ab0b
fix: merge conflict
mdneyazahmad 0894d1a
fix: merge conflict
mdneyazahmad ac07413
refactor: form components
mdneyazahmad 98e0061
Merge branch 'main' into fix/7916-accessibility
mdneyazahmad df17655
style: fix eslint error
mdneyazahmad b6dfd9e
Merge branch 'main' into fix/7916-accessibility
mdneyazahmad c0d70f6
feat: add form submit on enter key press
mdneyazahmad 2d9e717
Merge branch 'main' into fix/7916-accessibility
mdneyazahmad 0785afe
fix: temporarily disable press on enter
mdneyazahmad 81ec3f0
refactor: rename variable names
mdneyazahmad a944918
fix: merge conflict
mdneyazahmad 3272d34
fix: add missing prop
mdneyazahmad d5bf3b1
refactor: form submit component
mdneyazahmad 8a3286b
docs: update comments
mdneyazahmad 796bd14
feat: add submit on enter press for multiline text input
mdneyazahmad acaf7c5
docs: update comments
mdneyazahmad b6fe28e
docs: update comments
mdneyazahmad 7d33938
docs: update comment
mdneyazahmad 901fd3a
Merge branch 'main' into fix/7916-accessibility
mdneyazahmad 4bd8ca7
fix: merge conflict
mdneyazahmad 18f9f57
Merge branch 'main' into fix/7916-accessibility
mdneyazahmad ac9019d
fix(WorkspaceInvitePage): submit form with
mdneyazahmad d8d12c9
fix: merge conflict
mdneyazahmad d7b0a2d
merge main
mdneyazahmad 6dc6c4d
style: fix lint error
mdneyazahmad 89a5a6b
fix: merge conflict
mdneyazahmad 8f46d97
chore: resolve merge conflicts
mdneyazahmad 8992709
fix: add style proptype
mdneyazahmad e952bca
fix: style proptype error
mdneyazahmad 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 hidden or 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 hidden or 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 hidden or 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'; | ||
| import stylePropTypes from '../../styles/stylePropTypes'; | ||
|
|
||
| const propTypes = { | ||
| /* A function to execute when form is submitted with ENTER */ | ||
| onSubmit: PropTypes.func.isRequired, | ||
|
|
||
| /** Children to wrap with FormSubmit. */ | ||
| children: PropTypes.node.isRequired, | ||
|
|
||
| /** Container styles */ | ||
| style: stylePropTypes, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| style: [], | ||
| }; | ||
|
|
||
| export {propTypes, defaultProps}; | ||
This file contains hidden or 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,59 @@ | ||
| import React from 'react'; | ||
| import lodashGet from 'lodash/get'; | ||
| import {View} from 'react-native'; | ||
| import * as formSubmitPropTypes from './formSubmitPropTypes'; | ||
|
|
||
| // This is a wrapper component to handle the ENTER key press, and submit the form. | ||
| class FormSubmit extends React.Component { | ||
|
mdneyazahmad marked this conversation as resolved.
|
||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.submitForm = this.submitForm.bind(this); | ||
| } | ||
|
|
||
| /** | ||
| * Calls the submit callback when ENTER is pressed on a form element. | ||
| * @param {Object} event | ||
| */ | ||
|
|
||
|
mdneyazahmad marked this conversation as resolved.
|
||
| submitForm(event) { | ||
|
mdneyazahmad marked this conversation as resolved.
|
||
| // ENTER is pressed with modifier key, do not submit the form | ||
| if (event.shiftKey || event.key !== 'Enter') { | ||
| return; | ||
| } | ||
|
|
||
| const tagName = lodashGet(event, 'target.tagName', ''); | ||
|
|
||
| // ENTER is pressed on INPUT or SELECT element, call the submit callback. | ||
| if (tagName === 'INPUT' || tagName === 'SELECT') { | ||
| this.props.onSubmit(); | ||
| return; | ||
| } | ||
|
|
||
| // Pressing Enter on TEXTAREA element adds a new line. When `dataset.submitOnEnter` prop is passed, call the submit callback. | ||
| if (tagName === 'TEXTAREA' && lodashGet(event, 'target.dataset.submitOnEnter', 'false') === 'true') { | ||
| this.props.onSubmit(); | ||
| return; | ||
| } | ||
|
|
||
| // ENTER is pressed on checkbox element, call the submit callback. | ||
| if (lodashGet(event, 'target.role') === 'checkbox') { | ||
| this.props.onSubmit(); | ||
| } | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
|
|
||
| // React-native-web prevents event bubbling on TextInput for key presses | ||
| // https://github.com/necolas/react-native-web/blob/fa47f80d34ee6cde2536b2a2241e326f84b633c4/packages/react-native-web/src/exports/TextInput/index.js#L272 | ||
| // Thus use capture phase. | ||
| <View onKeyDownCapture={this.submitForm} style={this.props.style}>{this.props.children}</View> | ||
|
mdneyazahmad marked this conversation as resolved.
luacmartins marked this conversation as resolved.
|
||
| ); | ||
| } | ||
| } | ||
|
|
||
| FormSubmit.propTypes = formSubmitPropTypes.propTypes; | ||
| FormSubmit.defaultProps = formSubmitPropTypes.defaultProps; | ||
|
|
||
| export default FormSubmit; | ||
This file contains hidden or 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,11 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import * as formSubmitPropTypes from './formSubmitPropTypes'; | ||
|
|
||
| const FormSubmit = props => <View style={props.style}>{props.children}</View>; | ||
|
|
||
| FormSubmit.propTypes = formSubmitPropTypes.propTypes; | ||
| FormSubmit.defaultProps = formSubmitPropTypes.defaultProps; | ||
| FormSubmit.displayName = 'FormSubmit'; | ||
|
|
||
| export default FormSubmit; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.