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

Add aria-labels #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/Autowhatever.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Autowhatever extends Component {
getSectionItems: PropTypes.func, // This function gets a section and returns its items, which will be passed into `renderItem` for rendering.
containerProps: PropTypes.object, // Arbitrary container props
inputProps: PropTypes.object, // Arbitrary input props
ariaLabel: PropTypes.string, // Sets aria-label
itemProps: PropTypes.oneOfType([ // Arbitrary item props
PropTypes.object,
PropTypes.func
Expand Down Expand Up @@ -71,6 +72,7 @@ export default class Autowhatever extends Component {
itemProps: emptyObject,
highlightedSectionIndex: null,
highlightedItemIndex: null,
ariaLabel: 'search',
theme: defaultTheme
};

Expand Down Expand Up @@ -300,7 +302,7 @@ export default class Autowhatever extends Component {
const { theme } = this;
const {
id, multiSection, renderInputComponent, renderItemsContainer,
highlightedSectionIndex, highlightedItemIndex
highlightedSectionIndex, highlightedItemIndex, ariaLabel
} = this.props;
const { isInputFocused } = this.state;
const renderedItems = multiSection ? this.renderSections() : this.renderItems();
Expand All @@ -312,6 +314,7 @@ export default class Autowhatever extends Component {
'aria-haspopup': 'listbox',
'aria-owns': itemsContainerId,
'aria-expanded': isOpen,
'aria-label': ariaLabel,
...theme(
`react-autowhatever-${id}-container`,
'container',
Expand All @@ -325,6 +328,7 @@ export default class Autowhatever extends Component {
autoComplete: 'off',
'aria-autocomplete': 'list',
'aria-controls': itemsContainerId,
'aria-label' : 'suggestions',
'aria-activedescendant': ariaActivedescendant,
...theme(
`react-autowhatever-${id}-input`,
Expand Down