-
Notifications
You must be signed in to change notification settings - Fork 46
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
**Feature:** GO HARD on a11y #922
Conversation
db3eec2
to
8b40d29
Compare
7cf6608
to
ef00b1d
Compare
src/useUniqueId/index.ts
Outdated
import nanoid from "nanoid" | ||
import { useRef } from "react" | ||
|
||
export const useUniqueId = (defaultId: string | null = null) => { |
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.
export const useUniqueId = (defaultId: string | null = null) => React.useState(defaultId || nanoid)[0] as string;
Does snapshot tests fail because of this jestjs/jest#7094? UPD On the second run I got this jestjs/jest#8069, which is resolved in 24.3.0 |
src/Input/Input.Field.tsx
Outdated
<Container fullWidth={fullWidth} withLabel={Boolean(label)}> | ||
{shouldShowIconButton && renderButton()} | ||
<Field | ||
aria-labelledby={label ? `input-label-${id}` : undefined} |
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.
ariaLabelledby
?
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.
Also move it to Input/Input.tsx
so
aria-describedby={hint ? `input-hint-${id}` : undefined}
would be in the same file as
{hint && <Hint textId={`input-hint-${uniqueId}`}>{hint}</Hint>}
@@ -55,12 +55,15 @@ export const FormFieldControl = styled("div")(({ theme }) => ({ | |||
":hover": { | |||
color: theme.color.text.default, | |||
}, | |||
" *": { |
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.
Is it the same as "& *": {
?
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.
No. It is equivalent to "> *"
instead. 🙂
|
||
type ResizeOptions = "none" | "both" | "vertical" | "horizontal" | ||
|
||
export interface TextareaProps extends DefaultProps { | ||
/** What is the identifier of this textarea? */ | ||
id?: string |
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.
tabIndex
? Maybe introduce type AccessibleInput = { ... }
and then reuse it across input, textarea, autocomplete 🤔
src/Input/Input.Field.tsx
Outdated
<Field | ||
aria-labelledby={label ? `input-label-${id}` : undefined} | ||
aria-describedby={hint ? `input-hint-${id}` : undefined} | ||
aria-label={label} |
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.
do we need both aria-labelledby
and aria-label
?
Thanks! Co-Authored-By: TejasQ <hello@tej.as>
Summary
This PR fixes a number of issues with Inputs:
- Odd behavior when used without/with labels
- Fix spacing when an Input has an error AND a label
styled
importid
s for screen readersInput
s accessible: witharia
properties and correct label handlingAutocomplete
to use hooks and support IDsTo Do
Textarea
Open separate PRs for
Select
Checkbox
Switch
Toggle
To be tested
Me
localhost:6060
Tester 1
Tester 2