Skip to content

Commit 0201006

Browse files
committed
Fix small bug with the aria-activedescendant
1 parent f97d15f commit 0201006

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/SLDSLookup/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SLDSLookup extends React.Component {
2626
searchTerm: '',
2727
isOpen:false,
2828
selectedItem: null,
29-
activeIndex:0,
29+
activeIndex:null,
3030
};
3131
}
3232

@@ -40,7 +40,7 @@ class SLDSLookup extends React.Component {
4040

4141
decreaseIndex(){
4242
this.setState({
43-
activeIndex: this.state.activeIndex >= 0 ? this.state.activeIndex - 1 : this.props.items.length
43+
activeIndex: this.state.activeIndex > 0 ? this.state.activeIndex - 1 : this.props.items.length
4444
})
4545
}
4646

@@ -74,6 +74,7 @@ class SLDSLookup extends React.Component {
7474

7575
//If user hits tab key, move aria activedescendant to first menu item
7676
if(event.keyCode === KEYS.TAB){
77+
this.setState({activeIndex: 0});
7778
EventUtil.trapImmediate(event);
7879
}
7980
//If user hits down key, advance aria activedescendant to next item
@@ -124,7 +125,7 @@ class SLDSLookup extends React.Component {
124125
aria-label="lookup"
125126
aria-haspopup="true"
126127
aria-autocomplete="list"
127-
aria-activedescendant={"item-" + this.state.activeIndex}
128+
aria-activedescendant={this.state.activeIndex !== null ? "item-" + this.state.activeIndex : ""}
128129
aria-expanded={this.state.isOpen}
129130
role="combobox"
130131
onChange={this.handleChange.bind(this)}

0 commit comments

Comments
 (0)