Skip to content

Commit

Permalink
Make country code button a combobox
Browse files Browse the repository at this point in the history
This is a fix for #2
The country code button should still have role="combobox".
This role communicates that the component will open a listbox.
This is the case of a Select-Only Combobox
https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html

Fix broken tests
  • Loading branch information
VladyslavBondarenko committed Nov 11, 2022
1 parent 37e921d commit 00da39b
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions __tests__/FlagDropDown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ describe('FlagDropDown', function () { // eslint-disable-line func-names
const flagComponent = subject.find(FlagDropDown);

const result = [{
name: 'South Korea (대한민국)',
name: 'South Korea',
iso2: 'kr',
dialCode: '82',
priority: 0,
areaCodes: null,
}, {
name: 'Taiwan (台灣)',
name: 'Taiwan',
iso2: 'tw',
dialCode: '886',
priority: 0,
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('FlagDropDown', function () { // eslint-disable-line func-names

expect(expected).toEqual({
currentNumber: '',
name: 'Japan (日本)',
name: 'Japan',
iso2: 'jp',
dialCode: '81',
priority: 0,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('utils', () => {

it('getCountryData', () => {
const result = {
name: 'Taiwan (台灣)',
name: 'Taiwan',
iso2: 'tw',
dialCode: '886',
priority: 0,
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/example.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/components/CountryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CountryList extends Component {
className={ className }
id={ this.props.countryListId }
role="listbox"
tabIndex="-1"
>
{ preferredOptions }
{ divider }
Expand Down
4 changes: 2 additions & 2 deletions src/components/FlagDropDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ class FlagDropDown extends Component {
onClick={ this.props.clickSelectedFlag }
onKeyDown={ this.props.handleSelectedFlagKeydown }
title={ this.props.titleTip }
role="combobox"
aria-controls={ countryListId }
aria-owns={ countryListId }
aria-autocomplete="none"
aria-activedescendant={ this.getItemId(this.props.highlightedCountry) }
aria-expanded={ this.props.showDropdown }
aria-haspopup="listbox" // eslint-disable-line
>
<div className={ flagClass } />
{ genSelectedDialCode() }
Expand Down

0 comments on commit 00da39b

Please sign in to comment.