cengage / react-magma

https://react-magma.cengage.com
MIT License
21 stars 11 forks source link

Input - Character counter - Improved a11y #1255

Open orion-cengage opened 2 months ago

orion-cengage commented 2 months ago

CENG_3306

Docs: https://react-magma.cengage.com/version/4.3.0/api/input/

Success Criteria: https://www.w3.org/WAI/WCAG21/Understanding/name-role-value

In the Character Counter example, the character count is announced to assistive technology using an aria-live region. The character count is announced but then is immediately followed by what was typed into the input so the message could be missed.

One approach for improving this would be to leave the visual character count message where it is then to have a visually hidden aria-live region below that is announced after the user has finished typing for a short period of time.

silvalaura commented 3 weeks ago

An additional use case to address/test:

export function Example() {
  const [value, setValue] = useState("");

  return (
    <>
      <Input
        errorMessage={!value && "Empty value"}
        maxCount={4}
        value={value}
        onChange={(e) => setValue(e.target.value)}
        labelText="Default Character Counter"
      />
      <Button>Send</Button>
    </>
  );
}

image