Skip to content
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

Merged
merged 30 commits into from
Mar 11, 2019
Merged

**Feature:** GO HARD on a11y #922

merged 30 commits into from
Mar 11, 2019

Conversation

TejasQ
Copy link
Contributor

@TejasQ TejasQ commented Feb 14, 2019

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

  • Fix cursors on Input buttons
  • Refactor legacy styled import
  • Tooltips now have ids for screen readers
  • Make all Inputs accessible: with aria properties and correct label handling
  • Update all examples
  • Refactor Autocomplete to use hooks and support IDs

To Do

  • Make the same changes to Textarea

Open separate PRs for

  • Make the same changes to Select
  • Make the same changes to Checkbox
  • Make the same changes to Switch
  • Make the same changes to Toggle

To be tested

Me

  • No error or warning in the console on localhost:6060

Tester 1

  • Things look good on the demo.

Tester 2

  • Things look good on the demo.

@TejasQ TejasQ self-assigned this Feb 14, 2019
@TejasQ TejasQ changed the title **Fix:** GO HARD on a11y **Feature:** GO HARD on a11y Feb 14, 2019
import nanoid from "nanoid"
import { useRef } from "react"

export const useUniqueId = (defaultId: string | null = null) => {
Copy link
Contributor

@stereobooster stereobooster Mar 7, 2019

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;

source https://dev.to/alutom/comment/984j

@stereobooster
Copy link
Contributor

stereobooster commented Mar 7, 2019

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

<Container fullWidth={fullWidth} withLabel={Boolean(label)}>
{shouldShowIconButton && renderButton()}
<Field
aria-labelledby={label ? `input-label-${id}` : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ariaLabelledby?

Copy link
Contributor

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,
},
" *": {
Copy link
Contributor

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 "& *": {?

Copy link
Contributor Author

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
Copy link
Contributor

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 🤔

@stereobooster
Copy link
Contributor

lock icon is not focusable
Screenshot 2019-03-11 at 15 41 13

I'm not sure how this suppose to work. Copy button is not focusable.
Screenshot 2019-03-11 at 15 41 05

<Field
aria-labelledby={label ? `input-label-${id}` : undefined}
aria-describedby={hint ? `input-hint-${id}` : undefined}
aria-label={label}
Copy link
Contributor

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?

@TejasQ TejasQ merged commit fd66963 into master Mar 11, 2019
@TejasQ TejasQ deleted the fix/inputs branch March 11, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants