Skip to content

Commit a7c219e

Browse files
author
vikasrohit
committed
AS#111383418066580, Autocomplete the search text on forward arrow key
-- Handled case where there was no search suggestion
1 parent a92615d commit a7c219e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/SearchBar/SearchBar.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ class SearchBar extends Component {
9999
this.search()
100100
})
101101
} else if (eventKey === 39) { // right arrow key is pressed
102-
const suggestion = this.state.suggestions[0]
103-
this.refs.searchValue.value = suggestion
104-
// trigger the change event handler
105-
this.onChange()
102+
const suggestion = this.state.suggestions.length > 0 ? this.state.suggestions[0] : null
103+
if (suggestion) {
104+
this.refs.searchValue.value = suggestion
105+
// trigger the change event handler
106+
this.onChange()
107+
}
106108
}
107109
}
108110

0 commit comments

Comments
 (0)