Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

[fixed] #368: missing label for input field (a11y) #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class Autocomplete extends React.Component {

static propTypes = {
/**
* The items to display in the dropdown menu
* The label for a11y compliance
*/
label: PropTypes.string,
/**
* The value to display in the input field
*/
items: PropTypes.array.isRequired,
/**
Expand Down Expand Up @@ -161,6 +165,7 @@ class Autocomplete extends React.Component {

static defaultProps = {
value: '',
label: 'autocomplete',
wrapperProps: {},
wrapperStyle: {
display: 'inline-block'
Expand Down Expand Up @@ -576,6 +581,7 @@ class Autocomplete extends React.Component {
...inputProps,
role: 'combobox',
'aria-autocomplete': 'list',
'aria-label': this.props.label,
'aria-expanded': open,
autoComplete: 'off',
ref: this.exposeAPI,
Expand Down
2 changes: 2 additions & 0 deletions lib/__tests__/Autocomplete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ describe('Autocomplete isItemSelectable', () => {
autocompleteWrapper.setProps({ value: 'new hrhrhhrr' })
expect(autocompleteWrapper.state('highlightedIndex')).toBe(null)
})

})

describe('Public imperative API', () => {
Expand All @@ -771,3 +772,4 @@ describe('Public imperative API', () => {
expect(ac.isInputFocused()).toBe(false)
})
})

2 changes: 2 additions & 0 deletions lib/__tests__/__snapshots__/Autocomplete-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Autocomplete.props.renderInput should be invoked in \`render\` to creat
Object {
"aria-autocomplete": "list",
"aria-expanded": false,
"aria-label": "autocomplete",
"autoComplete": "off",
"foo": "bar",
"onBlur": [Function],
Expand All @@ -29,6 +30,7 @@ exports[`Autocomplete.props.renderInput should be invoked in \`render\` to creat
<input
aria-autocomplete="list"
aria-expanded={false}
aria-label="autocomplete"
autoComplete="on"
foo="bar"
onBlur={[Function]}
Expand Down
Loading