Baseweb: [Accessibility] Duplicate IDs are present in Input and Textarea components

Created on 5 Sep 2018  路  2Comments  路  Source: uber/baseweb

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

An expected behavior for a standard Input (with an associated Label) is to have a unique ID for each pairing.

Current Behavior

The current Input and Textarea components are providing a defaultProp for ID using the getBuiId utility. Since defaultProps is a static method and it isn't called on instances of the class, the ID is being duplicated across all usages.

Example of htmlFor duplication in Label:

2018-09-05 12-47-02 2018-09-05 12_47_35

Storybook a11y failures:

screen shot 2018-09-05 at 12 47 47 pm

Context

I'm not too familiar with the layout of this repo, but I have a simple commit (https://github.com/austin94/baseui/commit/c39199a8745065d796eb8643de3333a8d071abcf) that includes some fixes for this issue.

It includes:

  • Remove ID defaultProp from all components
  • Generate a unique ID for each instance, similar to the Popover implementation

    • Not applied to BaseInput and TextArea since there are no associated Labels that require it

  • Update snapshots and add htmlFor assertion

If any of this seems reasonable I can open a PR if wanted. Thanks 馃憢!

Your Environment

| Tech | Version |
| ------- | ------- |
| Base UI | master |
| React | ^16.4.0 |
| browser | Chrome |
| node.js | v9.11.1 |

Steps to Reproduce

https://baseui.netlify.com/?selectedKind=Input&selectedStory=Controlled%20and%20uncontrolled%20input&full=0&addons=1&stories=1&panelRight=0&addonPanel=REACT_STORYBOOK%2Freadme%2Fpanel

bugfix

Most helpful comment

can you open a pull request with your changes

Will do.

All 2 comments

thanks a lot for reporting it @austin94 - can you open a pull request with your changes?

can you open a pull request with your changes

Will do.

Was this page helpful?
0 / 5 - 0 ratings