Skip to content

Commit

Permalink
Merge pull request #393 from alphagov/aria-selected-as-string-rebased
Browse files Browse the repository at this point in the history
Aria selected as string rebased
  • Loading branch information
NickColley committed Nov 14, 2019
2 parents 4bebed4 + 83d7985 commit fe3ea11
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- [Pull request #388: Set aria-selected as a string instead of a boolean to avoid being dropped.](https://github.com/alphagov/accessible-autocomplete/pull/388)

## 2.0.1 - 2019-10-07

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/accessible-autocomplete.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.preact.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/accessible-autocomplete.react.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export default class Autocomplete extends Component {

return (
<li
aria-selected={focused === index}
aria-selected={focused === index ? 'true' : 'false'}
className={`${optionClassName}${optionModifierFocused}${optionModifierOdd}`}
dangerouslySetInnerHTML={{ __html: this.templateSuggestion(option) + iosPosinsetHtml }}
id={`${id}__option--${index}`}
Expand Down
11 changes: 11 additions & 0 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ const basicExample = () => {
})
}

it('should set aria-selected to true on selected option and false on other options', () => {
browser.click(input)
browser.setValue(input, 'ita')
browser.addValue(input, ['ArrowDown'])
expect(browser.$(firstOption).getAttribute('aria-selected')).to.equal('true')
expect(browser.$(secondOption).getAttribute('aria-selected')).to.equal('false')
browser.addValue(firstOption, ['ArrowDown'])
expect(browser.$(firstOption).getAttribute('aria-selected')).to.equal('false')
expect(browser.$(secondOption).getAttribute('aria-selected')).to.equal('true')
})

describe('keyboard use', () => {
it('should allow typing', () => {
browser.click(input)
Expand Down

0 comments on commit fe3ea11

Please sign in to comment.