Skip to content

Commit 35904f6

Browse files
author
Daniel Schaefer
committed
[fixed] reactjs#309 - autoHighlight not working unless match is beginning of an item
1 parent 220044a commit 35904f6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Autocomplete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class Autocomplete extends React.Component {
375375
const itemValue = getItemValue(matchedItem)
376376
const itemValueDoesMatch = (itemValue.toLowerCase().indexOf(
377377
value.toLowerCase()
378-
) === 0)
378+
) > -1)
379379
if (itemValueDoesMatch) {
380380
return { highlightedIndex: index }
381381
}

lib/__tests__/Autocomplete-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('Autocomplete acceptance tests', () => {
6565
it('should highlight top match when `props.value` changes', () => {
6666
const tree = mount(AutocompleteComponentJSX({}))
6767
expect(tree.state('highlightedIndex')).toEqual(null)
68-
tree.setProps({ value: 'a' })
68+
tree.setProps({ value: 'ri' })
6969
expect(tree.state('highlightedIndex')).toEqual(0)
7070
})
7171

0 commit comments

Comments
 (0)