Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
feat(autocomplete): add aria-label to buttons
Browse files Browse the repository at this point in the history
Add aria-label attributes to be compliance with
the accessibility standard and make the autocomplete
form render correctly on screen readers.

#470
  • Loading branch information
kontrollanten authored and raphi committed Mar 5, 2018
1 parent dfa5747 commit 3b4fe14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function places(options) {

const clear = document.createElement('button');
clear.setAttribute('type', 'button');
clear.setAttribute('aria-label', 'clear');
clear.classList.add(`${prefix}-input-icon`);
clear.classList.add(`${prefix}-icon-clear`);
clear.innerHTML = clearIcon;
Expand All @@ -118,6 +119,7 @@ export default function places(options) {

const pin = document.createElement('button');
pin.setAttribute('type', 'button');
pin.setAttribute('aria-label', 'focus');
pin.classList.add(`${prefix}-input-icon`);
pin.classList.add(`${prefix}-icon-pin`);
pin.innerHTML = pinIcon;
Expand Down
2 changes: 2 additions & 0 deletions src/places.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ describe('places', () => {
);
const pinButton = document.querySelector('.ap-icon-pin');
expect(clearButton.innerHTML).toEqual('clear');
expect(clearButton.getAttribute('aria-label')).toEqual('clear');

placesInstance.once('clear', () => {
expect(autocomplete.__instance.autocomplete.setVal).toBeCalledWith('');
Expand All @@ -263,6 +264,7 @@ describe('places', () => {
'button.ap-input-icon.ap-icon-pin'
);
expect(pinButton.style.display).toEqual('');
expect(pinButton.getAttribute('aria-label')).toEqual('focus');
});

describe('input listener', () => {
Expand Down

0 comments on commit 3b4fe14

Please sign in to comment.