-
Notifications
You must be signed in to change notification settings - Fork 3
Accessibility/sr for error for autosuggest #2139
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b6df8d
add current state
judithmh 9d4bc56
Merge branch 'main' into accessibility/sr-for-error-for-autosuggest
judithmh 3319d61
undo changes in noOptionsMessage
judithmh fa6eae3
undo changes in autoSuggest
judithmh 68d4b5d
add comment to explain necessity of custom props for cutom input
judithmh f482bf7
add test for aria-describedy for autosuggest
judithmh c46386e
Merge branch 'main' into accessibility/sr-for-error-for-autosuggest
judithmh 8bd5893
Merge branch 'main' into accessibility/sr-for-error-for-autosuggest
judithmh 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
51 changes: 34 additions & 17 deletions
51
app/components/inputs/autoSuggestInput/customComponents/CustomInput.tsx
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 |
|---|---|---|
| @@ -1,22 +1,39 @@ | ||
| import { components, type InputProps } from "react-select"; | ||
| import { | ||
| components, | ||
| type InputProps, | ||
| type Props, | ||
| type GroupBase, | ||
| } from "react-select"; | ||
| import type { DataListOptions } from "~/services/dataListOptions/getDataListOptions"; | ||
| import { INPUT_CHAR_LIMIT } from "~/services/validation/inputlimits"; | ||
|
|
||
| const CustomInput = (props: InputProps<DataListOptions, false>) => ( | ||
| <components.Input | ||
| // avoid to clear the previous auto suggestion input when press enter | ||
| // this cannot be tested, thus manually tested with device(s) | ||
| onKeyDown={(e) => { | ||
| if (e.key === "Enter" && !props.selectProps.menuIsOpen) { | ||
| e.preventDefault(); | ||
| } | ||
| }} | ||
| {...props} | ||
| maxLength={INPUT_CHAR_LIMIT} | ||
| aria-required={props.selectProps.className?.includes( | ||
| "auto-suggest-input-required", | ||
| )} | ||
| /> | ||
| ); | ||
| //Will become obsolete with the next version bump: https://github.com/JedWatson/react-select/pull/6016 | ||
| type CustomSelectProps = Props< | ||
| DataListOptions, | ||
| false, | ||
| GroupBase<DataListOptions> | ||
| > & { | ||
| "aria-describedby": string; | ||
| }; | ||
|
|
||
| const CustomInput = (props: InputProps<DataListOptions, false>) => { | ||
| const selectProps = props.selectProps as CustomSelectProps; | ||
| return ( | ||
| <components.Input | ||
| // avoid to clear the previous auto suggestion input when press enter | ||
| // this cannot be tested, thus manually tested with device(s) | ||
| onKeyDown={(e) => { | ||
|
Member
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. Can the testing library be used to test this behaviour? |
||
| if (e.key === "Enter" && !props.selectProps.menuIsOpen) { | ||
| e.preventDefault(); | ||
| } | ||
| }} | ||
| {...props} | ||
| maxLength={INPUT_CHAR_LIMIT} | ||
| aria-describedby={selectProps["aria-describedby"]} | ||
| aria-required={props.selectProps.className?.includes( | ||
| "auto-suggest-input-required", | ||
| )} | ||
| /> | ||
| ); | ||
| }; | ||
| export default CustomInput; | ||
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.