Skip to content

Commit dcb042e

Browse files
committed
navigation fix
1 parent d0ce961 commit dcb042e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/SLDSLookup/index.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ class SLDSLookup extends React.Component {
166166
// Using down/up keys, set Focus on list item and assign it to aria-activedescendant attribute in input.
167167
// Need to keep track of filtered list length to be able to increment/decrement the focus index so it's contained to the number of available list items.
168168
increaseIndex() {
169-
if(filteredItem && filteredItem.data.type === 'section'){
170-
this.state.focusIndex++;
171-
}
172169
let numFocusable = this.getNumFocusableItems();
173170
let nextFocusIndex = this.state.focusIndex < numFocusable ? this.state.focusIndex + 1 : 0;
174171
const filteredItem = this.refs.menu.getFilteredItemForIndex(nextFocusIndex);
@@ -180,7 +177,12 @@ class SLDSLookup extends React.Component {
180177

181178
decreaseIndex() {
182179
let numFocusable = this.getNumFocusableItems();
183-
this.setState({ focusIndex: this.state.focusIndex > 0 ? this.state.focusIndex - 1 : numFocusable});
180+
let prevFocusIndex = this.state.focusIndex > 0 ? this.state.focusIndex - 1 : numFocusable;
181+
const filteredItem = this.refs.menu.getFilteredItemForIndex(prevFocusIndex);
182+
if(filteredItem && filteredItem.data.type === 'section'){
183+
prevFocusIndex--;
184+
}
185+
this.setState({ focusIndex: prevFocusIndex});
184186
}
185187

186188
setFocus(id) {

0 commit comments

Comments
 (0)