Skip to content

Commit

Permalink
FIX (aria)[#146]: add aria-expanded, closes #146
Browse files Browse the repository at this point in the history
  • Loading branch information
sanusart committed Dec 17, 2020
1 parent c321c09 commit c81026b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions __tests__/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ exports[`<Select/> component <Select/> is disabled 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-6 emotion-7"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -239,6 +241,8 @@ exports[`<Select/> component <Select/> renders correctly 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-6 emotion-7"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -396,6 +400,8 @@ exports[`<Select/> component <Select/> renders with clearable 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-8 emotion-9"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -547,6 +553,8 @@ exports[`<Select/> component <Select/> renders with custom search function 1`] =
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-6 emotion-7"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -711,6 +719,8 @@ exports[`<Select/> component <Select/> renders with loading 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-8 emotion-9"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -858,6 +868,8 @@ exports[`<Select/> component <Select/> renders with name 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-6 emotion-7"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -1022,6 +1034,8 @@ exports[`<Select/> component <Select/> renders with separator 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-8 emotion-9"
color="#0074D9"
direction="ltr"
Expand Down Expand Up @@ -1168,6 +1182,8 @@ exports[`<Select/> component <Select/> renders with short color 1`] = `
<div>
<div
aria-expanded={false}
aria-label="Dropdown select"
className="react-dropdown-select undefined emotion-6 emotion-7"
color="#000"
direction="ltr"
Expand Down
1 change: 1 addition & 0 deletions src/components/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const Dropdown = ({ props, state, methods }) => (
<React.Fragment>
{props.create && state.search && !valueExistInSelected(state.search, [...state.values, ...props.options], props) && (
<AddNew
role="button"
className={`${LIB_NAME}-dropdown-add-new`}
color={props.color}
onClick={() => methods.createNew(state.search)}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Item extends Component {
ref={this.item}
aria-selected={methods.isSelected(item)}
aria-disabled={item.disabled}
disabled={item.disabled}
aria-label={getByPath(item, props.labelField)}
disabled={item.disabled}
key={`${getByPath(item, props.valueField)}${getByPath(item, props.labelField)}`}
tabIndex="-1"
className={`${LIB_NAME}-item ${
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ export class Select extends Component {
<ClickOutside onClickOutside={(event) => this.dropDown('close', event)}>
<ReactDropdownSelect
onKeyDown={this.handleKeyDown}
aria-label="Dropdown select"
aria-expanded={this.state.dropdown}
onClick={(event) => this.dropDown('open', event)}
tabIndex={this.props.disabled ? '-1' : '0'}
direction={this.props.direction}
Expand Down

0 comments on commit c81026b

Please sign in to comment.